-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(benchmark): pallet smart contract - tft bridge - tfgrid #700
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just some general remarks. It might be nice if we could have some code that does setup like:
- create twin / node / farm
Somewhere in a seperate package (crate). Not sure if it will understand the context of the mock
or benchmarking though..
substrate-node/pallets/pallet-smart-contract/src/benchmarking.rs
Outdated
Show resolved
Hide resolved
// let cost = 46501499; | ||
// let lock = SmartContractModule::<T>::contract_number_of_cylces_billed(contract_id); | ||
// assert_eq!(lock.amount_locked.saturated_into::<u64>(), cost); | ||
// assert_eq!( | ||
// contract.contract_id, contract_id | ||
// ); | ||
// let contract_bill = types::ContractBill { | ||
// contract_id, | ||
// timestamp: <Timestamp<T>>::get().saturated_into::<u64>() / 1000, | ||
// discount_level: types::DiscountLevel::None, | ||
// amount_billed: cost as u128, | ||
// }; | ||
// assert_last_event::<T>(Event::ContractBilled(contract_bill).into()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
fn _create_node<T: Config>(source: T::AccountId) { | ||
let resources = ResourcesInput { | ||
hru: 1024 * GIGABYTE, | ||
sru: 512 * GIGABYTE, | ||
cru: 8, | ||
mru: 16 * GIGABYTE, | ||
}; | ||
|
||
// random location | ||
let location = LocationInput { | ||
city: get_city_name_input(b"Ghent"), | ||
country: get_country_name_input(b"Belgium"), | ||
latitude: get_latitude_input(b"12.233213231"), | ||
longitude: get_longitude_input(b"32.323112123"), | ||
}; | ||
|
||
assert_ok!(TfgridModule::<T>::create_node( | ||
RawOrigin::Signed(source.clone()).into(), | ||
1, | ||
resources, | ||
location, | ||
Vec::new().try_into().unwrap(), | ||
false, | ||
false, | ||
None, | ||
)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice if we could put this somewhere to be reused in other pallets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
but don't see an obvious way for the same reason you mentioned above
9277b4c
to
61bbd9a
Compare
Benchmarking pallets smart contract / tft bridge / tfgrid
Solves part of