Skip to content

Commit 00ff4b0

Browse files
committed
Merge remote-tracking branch 'jwasinger/wasm-tests' into wasm-tests
2 parents 9f3a43c + 7d83303 commit 00ff4b0

File tree

18 files changed

+696
-5
lines changed

18 files changed

+696
-5
lines changed

BlockchainTests/GeneralStateTests/stEWASMTests/.gitkeep

Whitespace-only changes.

BlockchainTests/bcEWASMTests/.gitkeep

Whitespace-only changes.

src/BlockchainTestsFiller/GeneralStateTests/stEWASMTests/.gitkeep

Whitespace-only changes.

src/BlockchainTestsFiller/bcEWASMTests/.gitkeep

Whitespace-only changes.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
call:
2+
env:
3+
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
4+
currentDifficulty: '0x020000'
5+
currentGasLimit: '89128960'
6+
currentNumber: '1'
7+
currentTimestamp: '1000'
8+
previousHash: 5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6
9+
pre:
10+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
11+
balance: '100000000000'
12+
code: ''
13+
nonce: '0x4'
14+
storage: {}
15+
deadbeef00000000000000000000000000000001:
16+
balance: '100000000000'
17+
nonce: ''
18+
storage: {}
19+
code: |
20+
(module
21+
(import "ethereum" "getCallDataSize" (func $getCallDataSize (result i32)))
22+
(import "ethereum" "storageStore" (func $storageStore (param i32 i32)))
23+
(import "debug" "printMemHex" (func $printMemHex (param i32 i32)))
24+
(memory 1)
25+
26+
(export "memory" (memory 0))
27+
(export "main" (func $main))
28+
29+
(func $main
30+
(i32.store (i32.const 0) (call $getCallDataSize))
31+
(call $printMemHex (i32.const 0) (i32.const 100))
32+
(call $printMemHex (i32.const 100) (i32.const 200))
33+
(call $storageStore (i32.const 100) (i32.const 0))
34+
)
35+
)
36+
deadbeef00000000000000000000000000000000:
37+
balance: '100000000000'
38+
nonce: ''
39+
storage: {}
40+
code: |
41+
(module
42+
(import "ethereum" "call" (func $call (param i64 i32 i32 i32 i32 i32 i32) (result i32)))
43+
(import "ethereum" "getBalance" (func $getBalance (param i32 i32)))
44+
(import "ethereum" "storageStore" (func $storageStore (param i32 i32)))
45+
(import "ethereum" "getAddress" (func $getAddress (param i32)))
46+
(import "debug" "printMemHex" (func $printMemHex (param i32 i32)))
47+
(memory 1 )
48+
(data (i32.const 0) "\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\ef\be\ad\de")
49+
(data (i32.const 52) "\42\04\20\42\04\20\42\00")
50+
(export "memory" (memory 0))
51+
(export "main" (func $main))
52+
53+
(func $main
54+
;; Memory layout:
55+
;; 0 - 20 bytes: address (4)
56+
;; 20 - 52 bytes: value (0)
57+
;; 52 - 56 bytes: data (0x42004200)
58+
;; 56 - 60 bytes: result
59+
(call $printMemHex (i32.const 0) (i32.const 20))
60+
(call $printMemHex (i32.const 20) (i32.const 32))
61+
(call $printMemHex (i32.const 52) (i32.const 4))
62+
(call $printMemHex (i32.const 56) (i32.const 4))
63+
;; gas addrOffset valOffset dataOffset dataLength resultOffset resultLength
64+
(call $call (i64.const 200000) (i32.const 0) (i32.const 20) (i32.const 52) (i32.const 4) (i32.const 56) (i32.const 4) )
65+
drop
66+
)
67+
)
68+
expect:
69+
- indexes:
70+
data: -1
71+
gas: -1
72+
value: -1
73+
network:
74+
- ALL
75+
result:
76+
deadbeef00000000000000000000000000000000:
77+
storage: {
78+
}
79+
deadbeef00000000000000000000000000000001:
80+
storage: {
81+
0: "0x4"
82+
}
83+
transaction:
84+
data:
85+
- '0x'
86+
gasLimit:
87+
- '0x6acfc0'
88+
gasPrice: '0x02'
89+
nonce: '0x04'
90+
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
91+
to: 'deadbeef00000000000000000000000000000000'
92+
value:
93+
- '0'
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
codeCopy:
2+
env:
3+
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
4+
currentDifficulty: '0x020000'
5+
currentGasLimit: '89128960'
6+
currentNumber: '1'
7+
currentTimestamp: '1000'
8+
previousHash: 5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6
9+
pre:
10+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
11+
balance: '100000000000'
12+
code: ''
13+
nonce: ''
14+
storage: {}
15+
deadbeef00000000000000000000000000000000:
16+
balance: '100000000000'
17+
code: |
18+
(module
19+
(import "ethereum" "codeCopy" (func $codeCopy (param i32 i32 i32)))
20+
(import "ethereum" "storageStore" (func $storageStore (param i32 i32)))
21+
(memory 1 )
22+
(export "memory" (memory 0))
23+
(export "main" (func $main))
24+
25+
(func $main
26+
(call $codeCopy (i32.const 0) (i32.const 0) (i32.const 10))
27+
(call $storageStore (i32.const 100) (i32.const 0))
28+
)
29+
)
30+
nonce: ''
31+
storage: {
32+
0: "0x00"
33+
}
34+
expect:
35+
- indexes:
36+
data: -1
37+
gas: -1
38+
value: -1
39+
network:
40+
- ALL
41+
result:
42+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
43+
balance: "99999957728"
44+
deadbeef00000000000000000000000000000000:
45+
storage: {
46+
0: "0x0f01000000016d736100"
47+
}
48+
transaction:
49+
data:
50+
- '0xffff'
51+
gasLimit:
52+
- '0x5000001'
53+
gasPrice: '0x02'
54+
nonce: '0x00'
55+
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
56+
to: 'deadbeef00000000000000000000000000000000'
57+
value:
58+
- '0'

src/GeneralStateTestsFiller/stEWASMTests/utils/convert_wast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def convert_state_test(file_name):
3131
if state_test[test_case]['pre'][addr]['code'] != '':
3232
state_test[test_case]['pre'][addr]['code'] = '0x'+wat2wasm(state_test[test_case]['pre'][addr]['code'], file_name)
3333

34-
if state_test[test_case]['transaction']['data'] != [''] and state_test[test_case]['transaction']['to'] == '':
34+
if state_test[test_case]['transaction']['data'] != '' and state_test[test_case]['transaction']['to'] == '':
3535
for i in range(0, len(state_test[test_case]['transaction']['data'])):
3636
state_test[test_case]['transaction']['data'][i] = '0x'+wat2wasm(state_test[test_case]['transaction']['data'][i], file_name)
3737

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
create:
2+
env:
3+
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
4+
currentDifficulty: '0x020000'
5+
currentGasLimit: '89128960'
6+
currentNumber: '1'
7+
currentTimestamp: '1000'
8+
previousHash: 5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6
9+
pre:
10+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
11+
balance: '100000000000'
12+
code: ''
13+
nonce: '0x4'
14+
storage: {}
15+
deadbeef00000000000000000000000000000000:
16+
balance: '100000000000'
17+
nonce: ''
18+
storage: {}
19+
code: |
20+
(module
21+
(import "ethereum" "create" (func $create (param i32 i32 i32 i32) (result i32)))
22+
(import "debug" "printMemHex" (func $printMemHex (param i32 i32)))
23+
(memory 1 )
24+
(export "memory" (memory 0))
25+
(export "main" (func $main))
26+
27+
(func $main
28+
;; value offset data offset length result offset
29+
(call $create (i32.const 0) (i32.const 16) (i32.const 0) (i32.const 0))
30+
drop
31+
)
32+
)
33+
expect:
34+
- indexes:
35+
data: -1
36+
gas: -1
37+
value: -1
38+
network:
39+
- ALL
40+
result:
41+
deadbeef00000000000000000000000000000000:
42+
storage: {
43+
}
44+
transaction:
45+
data:
46+
- '0x'
47+
gasLimit:
48+
- '0x6acfc0'
49+
gasPrice: '0x02'
50+
nonce: '0x04'
51+
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
52+
to: 'deadbeef00000000000000000000000000000000'
53+
value:
54+
- '0'
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
extCodeCopy:
2+
env:
3+
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
4+
currentDifficulty: '0x020000'
5+
currentGasLimit: '89128960'
6+
currentNumber: '1'
7+
currentTimestamp: '1000'
8+
previousHash: 5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6
9+
pre:
10+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
11+
balance: '100000000000'
12+
code: ''
13+
nonce: ''
14+
storage: {}
15+
deadbeef00000000000000000000000000000001:
16+
balance: '100000000000'
17+
nonce: ''
18+
storage: {}
19+
code: |
20+
(module
21+
(import "ethereum" "codeCopy" (func $codeCopy (param i32 i32 i32)))
22+
(import "ethereum" "storageStore" (func $storageStore (param i32 i32)))
23+
(memory 1 )
24+
(export "memory" (memory 0))
25+
(export "main" (func $main))
26+
27+
(func $main
28+
(call $codeCopy (i32.const 0) (i32.const 0) (i32.const 20))
29+
(call $storageStore (i32.const 100) (i32.const 0))
30+
)
31+
)
32+
deadbeef00000000000000000000000000000000:
33+
balance: '100000000000'
34+
code: |
35+
(module
36+
(import "ethereum" "externalCodeCopy" (func $externalCodeCopy (param i32 i32 i32 i32)))
37+
(import "ethereum" "storageStore" (func $storageStore (param i32 i32)))
38+
(import "ethereum" "getBalance" (func $getBalance (param i32 i32)))
39+
(memory 1 )
40+
(data (i32.const 0) "\10\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\ef\be\ad\de")
41+
(export "memory" (memory 0))
42+
(export "main" (func $main))
43+
44+
(func $main
45+
(call $getBalance (i32.const 0) (i32.const 100))
46+
;;(call $externalCodeCopy (i32.const 0) (i32.const 200) (i32.const 0) (i32.const 10))
47+
(call $storageStore (i32.const 100) (i32.const 200))
48+
)
49+
)
50+
nonce: ''
51+
storage: {
52+
0: "0x00"
53+
}
54+
expect:
55+
- indexes:
56+
data: -1
57+
gas: -1
58+
value: -1
59+
network:
60+
- ALL
61+
result:
62+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
63+
balance: "99999957728"
64+
transaction:
65+
data:
66+
- '0xffff'
67+
gasLimit:
68+
- '0x5000001'
69+
gasPrice: '0x02'
70+
nonce: '0x00'
71+
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
72+
to: 'deadbeef00000000000000000000000000000000'
73+
value:
74+
- '0'
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
getBalanceExt:
2+
env:
3+
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
4+
currentDifficulty: '0x020000'
5+
currentGasLimit: '89128960'
6+
currentNumber: '1'
7+
currentTimestamp: '1000'
8+
previousHash: 5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6
9+
pre:
10+
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
11+
balance: '100000000000'
12+
code: ''
13+
nonce: ''
14+
storage: {}
15+
deadbeef00000000000000000000000000000000:
16+
balance: '0x1234'
17+
code: ''
18+
nonce: '0x1'
19+
storage: {}
20+
deadbeef00000000000000000000000000000001:
21+
balance: '100000000000'
22+
code: |
23+
;; get balance of another account
24+
(module
25+
(import "ethereum" "getBalance" (func $getBalance (param i32 i32)))
26+
(import "ethereum" "storageStore" (func $storageStore (param i32 i32)))
27+
(import "debug" "printMemHex" (func $printMemHex (param i32 i32)))
28+
(memory 1 )
29+
(data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\ef\be\ad\de")
30+
(export "memory" (memory 0))
31+
(export "main" (func $main))
32+
(func $main
33+
(call $getBalance (i32.const 0) (i32.const 100))
34+
(call $storageStore (i32.const 200) (i32.const 100))
35+
)
36+
)
37+
nonce: ''
38+
storage: {}
39+
expect:
40+
- indexes:
41+
data: -1
42+
gas: -1
43+
value: -1
44+
network:
45+
- ALL
46+
result:
47+
deadbeef00000000000000000000000000000000:
48+
storage: {}
49+
deadbeef00000000000000000000000000000001:
50+
storage: {
51+
0: "0x1234"
52+
}
53+
transaction:
54+
data:
55+
- '0x'
56+
gasLimit:
57+
- '0x6acfc0'
58+
gasPrice: '0x02'
59+
nonce: '0x00'
60+
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
61+
to: 'deadbeef00000000000000000000000000000001'
62+
value:
63+
- '0'

0 commit comments

Comments
 (0)