Skip to content

Commit 78286b6

Browse files
committed
add some assertion in onchain test
1 parent 81958ad commit 78286b6

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

test/onChain/testBaseSepolia.sol

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,50 @@ pragma solidity ^0.8.24;
33

44
import "forge-std/Test.sol";
55
import "src/VotingPowerExchange.sol";
6+
import "src/ERC20UpgradeableTokenV1.sol";
67

78
contract TestBaseSepolia is Test {
89
VotingPowerExchange public votingPowerExchange;
910
address public constant DEPLOYED_CONTRACT_ADDRESS = 0x8016b49aFd80A62191296e630174C2352129349A; // the actual deployed address on Base Sepolia
1011

12+
ERC20UpgradeableTokenV1 public utilityToken;
13+
1114
function setUp() public {
1215
// Get the instance of the deployed contract
1316
votingPowerExchange = VotingPowerExchange(DEPLOYED_CONTRACT_ADDRESS);
17+
utilityToken = ERC20UpgradeableTokenV1(0x091dFFe4A5625420a998589E451A15c753073Cda);
1418
}
1519

1620
function testExchangeOnChain01() public {
1721
// Set up the state required for the test (if needed)
1822
// For example, simulate a user address
23+
uint256 balanceBefore = utilityToken.balanceOf(0x588A7E62547CB573084C8608486d60E567c573d0);
24+
25+
address sender = 0x588A7E62547CB573084C8608486d60E567c573d0;
26+
uint256 amount = 2000000000000000000;
27+
bytes32 nonce = bytes32(0x45a6cd4929f515c60c82473f16bc1fad9e8b95c04e18e76c7dfc9a6548cb5b60);
28+
uint256 timestamp = 1727871292;
29+
bytes memory signature = hex"bc9dd8b708b7ad5dd8dd68e422cd6b44ac6f6aebeabad4c1e52a1942e267c3af36e5d9aafff7fd8657444991613de3276a308bc858cc8e91e28f58142ff34faa1b";
30+
1931
address exchanger = 0x5aB0ffF1a51ee78F67247ac0B90C8c1f1f54c37F;
2032
vm.startPrank(exchanger);
2133

34+
2235
// Call the exchange function
2336
votingPowerExchange.exchange(
24-
0x588A7E62547CB573084C8608486d60E567c573d0,
25-
2000000000000000000,
26-
bytes32(0x45a6cd4929f515c60c82473f16bc1fad9e8b95c04e18e76c7dfc9a6548cb5b60),
27-
1727871292,
28-
hex"bc9dd8b708b7ad5dd8dd68e422cd6b44ac6f6aebeabad4c1e52a1942e267c3af36e5d9aafff7fd8657444991613de3276a308bc858cc8e91e28f58142ff34faa1b"
29-
); // Assuming exchange accepts a uint256 parameter
37+
sender,
38+
amount,
39+
nonce,
40+
timestamp,
41+
signature
42+
);
43+
vm.stopPrank();
3044

3145
// Make assertions to verify the results
32-
// assertEq(votingPowerExchange.balanceOf(user), 100, "Exchange failed");
33-
34-
vm.stopPrank();
46+
assertEq(
47+
utilityToken.balanceOf(0x588A7E62547CB573084C8608486d60E567c573d0),
48+
balanceBefore - 2000000000000000000,
49+
"Exchange failed"
50+
);
3551
}
3652
}

0 commit comments

Comments
 (0)