@@ -20,4 +20,40 @@ contract PythLazerTest is Test {
20
20
skip (2000 );
21
21
assert (! pythLazer.isValidSigner (address (2 )));
22
22
}
23
+
24
+ function test_verify_with_fee () public {
25
+ // Prepare dummy update and signer
26
+ address trustedSigner = 0xEfEf56cD66896f6799A90A4e4d512C330c094e44 ;
27
+ vm.prank (address (1 ));
28
+ pythLazer.updateTrustedSigner (trustedSigner, 3000000000000000 );
29
+ bytes memory update = hex "2a22999a577d3cc0202197939d736bc0dcf71b9dde7b9470e4d16fa8e2120c0787a1c0d744d0c39cc372af4d1ecf2d09e84160ca905f3f597d20e2eec144a446a0459ad600001c93c7d3750006240af373971c01010000000201000000000005f5e100 " ;
30
+
31
+ uint256 fee = pythLazer.verification_fee ();
32
+
33
+ address alice = makeAddr ("alice " );
34
+ vm.deal (alice, 1 ether);
35
+ address bob = makeAddr ("bob " );
36
+ vm.deal (bob, 1 ether);
37
+
38
+ // Alice provides appropriate fee
39
+ vm.prank (alice);
40
+ pythLazer.verifyUpdate { value: fee }(update);
41
+ assertEq (alice.balance, 1 ether - fee);
42
+
43
+ // Alice overpays and is refunded
44
+ vm.prank (alice);
45
+ pythLazer.verifyUpdate { value: 0.5 ether }(update);
46
+ assertEq (alice.balance, 1 ether - fee - fee);
47
+
48
+ // Bob does not attach a fee
49
+ vm.prank (bob);
50
+ vm.expectRevert ("Insufficient fee provided " );
51
+ pythLazer.verifyUpdate (update);
52
+ assertEq (bob.balance, 1 ether);
53
+
54
+ // Bob does not attach enough fees
55
+ vm.expectRevert ("Insufficient fee provided " );
56
+ pythLazer.verifyUpdate { value: 0.00001 ether }(update);
57
+ assertEq (bob.balance, 1 ether);
58
+ }
23
59
}
0 commit comments