@@ -74,7 +74,7 @@ tape('should run simple tx without errors', async (t) => {
74
74
t . end ( )
75
75
} )
76
76
77
- tape ( 'should fail when account balance overflows' , async t => {
77
+ tape ( 'should fail when account balance overflows (call) ' , async t => {
78
78
const vm = new VM ( )
79
79
const suite = setup ( vm )
80
80
@@ -84,11 +84,28 @@ tape('should fail when account balance overflows', async t => {
84
84
await suite . putAccount ( tx . from . toString ( 'hex' ) , from )
85
85
await suite . putAccount ( tx . to , to )
86
86
87
- shouldFail ( t ,
88
- suite . runTx ( { tx } ) ,
89
- ( e ) => t . equal ( e . message , 'Value overflow' )
90
- )
87
+ const res = await suite . runTx ( { tx } )
88
+
89
+ t . equal ( res . execResult . exceptionError . error , 'value overflow' )
90
+ t . equal ( vm . stateManager . _checkpointCount , 0 )
91
+ t . end ( )
92
+ } )
93
+
94
+ tape ( 'should fail when account balance overflows (create)' , async t => {
95
+ const vm = new VM ( )
96
+ const suite = setup ( vm )
91
97
98
+ const contractAddress = Buffer . from ( '37d6c3cdbc9304cad74eef8e18a85ed54263b4e7' , 'hex' )
99
+ const tx = getTransaction ( true , true , '0x01' , true )
100
+ const from = createAccount ( )
101
+ const to = createAccount ( '0x00' , ethUtil . MAX_INTEGER )
102
+ await suite . putAccount ( tx . from . toString ( 'hex' ) , from )
103
+ await suite . putAccount ( contractAddress , to )
104
+
105
+ const res = await suite . runTx ( { tx } )
106
+
107
+ t . equal ( res . execResult . exceptionError . error , 'value overflow' )
108
+ t . equal ( vm . stateManager . _checkpointCount , 0 )
92
109
t . end ( )
93
110
} )
94
111
@@ -117,15 +134,25 @@ function shouldFail (st, p, onErr) {
117
134
p . then ( ( ) => st . fail ( 'runTx didnt return any errors' ) ) . catch ( onErr )
118
135
}
119
136
120
- function getTransaction ( sign = false , calculageGas = false , value = '0x00' ) {
137
+ function getTransaction ( sign = false , calculageGas = false , value = '0x00' , createContract = false ) {
138
+ let to = '0x0000000000000000000000000000000000000000'
139
+ let data = '0x7f7465737432000000000000000000000000000000000000000000000000000000600057'
140
+
141
+ if ( createContract ) {
142
+ to = undefined
143
+ data = '0x6080604052348015600f57600080fd5b50603e80601d6000396000f3fe6080604052600080fdfea' +
144
+ '265627a7a723158204aed884a44fd1747efccba1447a2aa2d9a4b06dd6021c4a3bbb993021e0a909e' +
145
+ '64736f6c634300050f0032'
146
+ }
147
+
121
148
const privateKey = Buffer . from ( 'e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109' , 'hex' )
122
149
const txParams = {
123
150
nonce : '0x00' ,
124
151
gasPrice : 100 ,
125
152
gasLimit : 1000 ,
126
- to : '0x0000000000000000000000000000000000000000' ,
153
+ to : to ,
127
154
value : value ,
128
- data : '0x7f7465737432000000000000000000000000000000000000000000000000000000600057' ,
155
+ data : data ,
129
156
chainId : 3
130
157
}
131
158
0 commit comments