@@ -4,7 +4,7 @@ const fs = require('fs');
4
4
const path = require ( 'path' ) ;
5
5
6
6
const { expectRevert } = require ( '@openzeppelin/test-helpers' ) ;
7
- const { setupSigners, getAdmin, deployWasm, storeWasm, execute, isDocker, ABI , createTokenFactoryTokenAndMint, getSeiBalance} = require ( "./lib" ) ;
7
+ const { setupSigners, getAdmin, deployWasm, storeWasm, execute, isDocker, ABI , createTokenFactoryTokenAndMint, getSeiBalance, rawHttpDebugTraceWithCallTracer } = require ( "./lib" ) ;
8
8
9
9
10
10
describe ( "EVM Precompile Tester" , function ( ) {
@@ -17,6 +17,32 @@ describe("EVM Precompile Tester", function () {
17
17
admin = await getAdmin ( ) ;
18
18
} )
19
19
20
+ describe ( "EVM Bank Precompile Tester" , function ( ) {
21
+ const BankPrecompileContract = '0x0000000000000000000000000000000000001001' ;
22
+ let bank ;
23
+
24
+ before ( async function ( ) {
25
+ const signer = accounts [ 0 ] . signer
26
+ const contractABIPath = '../../precompiles/bank/abi.json' ;
27
+ const contractABI = require ( contractABIPath ) ;
28
+ // Get a contract instance
29
+ bank = new ethers . Contract ( BankPrecompileContract , contractABI , signer ) ;
30
+ } ) ;
31
+
32
+ it ( "Fails with 'execution reverted' not 'panic occurred' when insufficient gas is provided" , async function ( ) {
33
+ try {
34
+ const bankSendTx = await bank . sendNative ( accounts [ 1 ] . seiAddress , { value : 1 , gasLimit : 40000 } ) ;
35
+ await bankSendTx . wait ( ) ;
36
+ } catch ( error ) {
37
+ const txHash = error . receipt . hash
38
+ // should not get "panic occurred"
39
+ const trace = await rawHttpDebugTraceWithCallTracer ( txHash )
40
+ expect ( trace . result . error ) . to . not . include ( "panic" )
41
+ expect ( trace . result . error ) . to . include ( "execution reverted" )
42
+ }
43
+ } ) ;
44
+ } ) ;
45
+
20
46
describe ( "EVM Addr Precompile Tester" , function ( ) {
21
47
const AddrPrecompileContract = '0x0000000000000000000000000000000000001004' ;
22
48
let addr ;
@@ -72,6 +98,22 @@ describe("EVM Precompile Tester", function () {
72
98
const seiAddr = await addr . getSeiAddr ( unassociatedWallet . address ) ;
73
99
expect ( seiAddr ) . to . not . be . null ;
74
100
} ) ;
101
+
102
+ it ( "Fails with 'execution reverted' not 'panic occurred' when insufficient gas is provided" , async function ( ) {
103
+ const unassociatedWallet = hre . ethers . Wallet . createRandom ( ) ;
104
+ try {
105
+ // provide less than gas than needed to execute the transaction
106
+ const associatedAddrs = await addr . associatePubKey ( unassociatedWallet . publicKey . slice ( 2 ) , { gasLimit : 52000 } ) ;
107
+ await associatedAddrs . wait ( ) ;
108
+ expect . fail ( "Expected an error here since we provided insufficient gas" ) ;
109
+ } catch ( error ) {
110
+ const txHash = error . receipt . hash
111
+ // should not get "panic occurred"
112
+ const trace = await rawHttpDebugTraceWithCallTracer ( txHash )
113
+ expect ( trace . result . error ) . to . not . include ( "panic" ) ;
114
+ expect ( trace . result . error ) . to . include ( "execution reverted" ) ;
115
+ }
116
+ } ) ;
75
117
} ) ;
76
118
77
119
describe ( "EVM Gov Precompile Tester" , function ( ) {
0 commit comments