mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 18:28:01 +00:00
d9842b5427
The balance_of syscall is now available in pallet-revive. - Fix balance_of implementation to use correct runtime api - Add build_address_argument_store helper to be used for address arguments
67 lines
1.4 KiB
Solidity
67 lines
1.4 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8;
|
|
|
|
/* runner.json
|
|
{
|
|
"differential": true,
|
|
"actions": [
|
|
{
|
|
"Upload": {
|
|
"code": {
|
|
"Solidity": {
|
|
"contract": "ValueTester"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"Instantiate": {
|
|
"value": 1024,
|
|
"code": {
|
|
"Solidity": {
|
|
"contract": "Value"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"Call": {
|
|
"dest": {
|
|
"Instantiated": 0
|
|
},
|
|
"value": 123,
|
|
"data": "3fa4f245"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
*/
|
|
|
|
contract ValueTester {
|
|
constructor() payable {}
|
|
|
|
function balance_self() public view returns (uint ret) {
|
|
ret = address(this).balance;
|
|
}
|
|
}
|
|
|
|
contract Value {
|
|
constructor() payable {
|
|
ValueTester tester = new ValueTester{value: msg.value}();
|
|
|
|
// own account
|
|
assert(address(this).balance == 0);
|
|
|
|
// tester account
|
|
assert(address(tester).balance == msg.value);
|
|
assert(tester.balance_self() == msg.value);
|
|
|
|
// non-existant account
|
|
assert(address(0xdeadbeef).balance == 0);
|
|
}
|
|
|
|
function value() public payable returns (uint ret) {
|
|
ret = msg.value;
|
|
}
|
|
}
|