-
Notifications
You must be signed in to change notification settings - Fork 3
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: option to set msg::value in unit tests and track balances #31
base: main
Are you sure you want to change the base?
Conversation
proxy3.fund(TEN); | ||
|
||
// Call the first proxy. | ||
proxy1.sender_and_value(alice, ONE).pay_proxy(); |
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 think the "lazy" builder pattern should be optimal in our use case, since we are not expecting many arguments to trigger a call
assert_eq!(result, TEN + ONE + ONE + ONE); | ||
} | ||
|
||
#[motsu_proc::test] |
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.
We can add test cases with #[should_panic = "account ... has not enough balance"]
assertion once our addresses will be deterministic
}); | ||
|
||
// Fund accounts. | ||
alice.fund(TEN); |
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.
This is the new api to fund an account.
But we can actually add a default balance @0xNeshi wdt?
@@ -302,8 +490,16 @@ impl<ST: StorageType> ContractCall<'_, ST> { | |||
self.contract_ref.address | |||
} | |||
|
|||
/// Apply previously not reverted transactions. | |||
fn apply_not_reverted_transactions() { |
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.
Soon within this function we can can apply state from the previous transaction, if it wasn't reverted due to error (#32)
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.
Looks good in general, left few comments.
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.
Looks good to me but let's wait also for @0xNeshi review.
@@ -93,6 +90,22 @@ impl Context { | |||
self.storage().contract_address.replace(address) | |||
} | |||
|
|||
/// Set message value to `value` and return the previous value if any. |
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.
/// Set message value to `value` and return the previous value if any. | |
/// Set the message value to `value` and return the previous value if any. |
|
||
match self.call_contract(address, selector, &input[4..]) { | ||
/// Based on `result`, set the return data. | ||
/// Return 0 if `result` is `Ok`, otherwise return 1. |
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.
/// Return 0 if `result` is `Ok`, otherwise return 1. | |
/// Return 0 if `result` is `Ok`, otherwise 1. |
@@ -242,6 +300,91 @@ impl Context { | |||
self.router(address).exists() | |||
} | |||
|
|||
/// Check if `address` has enough funds to transfer `value` |
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.
/// Check if `address` has enough funds to transfer `value` | |
/// Check if `address` has enough funds to transfer `value`. |
Resolves #26
PR Checklist