forked from ethereum/tests
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for missing main in init code
Checks 1. that CREATE returns 1 (failure), 2. that result (created contract address) is empty
- Loading branch information
Showing
2 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
GeneralStateTests/stEWASMTests/initMalformedBytecodeNoMain.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"initMalformedBytecodeNoMain" : { | ||
"_info" : { | ||
"comment" : "", | ||
"filledwith" : "testeth 1.4.0", | ||
"lllcversion" : "Version: 0.4.20-develop.2018.1.14+commit.0c20b6da.Darwin.appleclang", | ||
"source" : "src/GeneralStateTestsFiller/stEWASMTests/initMalformedBytecodeNoMainFiller.yml", | ||
"sourceHash" : "f17ace063abb977049e8157544752da3ff07568b2189ecae991a6087a139a6c0" | ||
}, | ||
"env" : { | ||
"currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", | ||
"currentDifficulty" : "0x020000", | ||
"currentGasLimit" : "0x05500000", | ||
"currentNumber" : "0x01", | ||
"currentTimestamp" : "0x03e8", | ||
"previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" | ||
}, | ||
"post" : { | ||
"Byzantium" : [ | ||
{ | ||
"hash" : "0xa8398e170adc0d080f94b737c11aaabac17f09354f9ebf0b84b92d2bff060638", | ||
"indexes" : { | ||
"data" : 0, | ||
"gas" : 0, | ||
"value" : 0 | ||
}, | ||
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" | ||
} | ||
] | ||
}, | ||
"pre" : { | ||
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { | ||
"balance" : "0x174876e800", | ||
"code" : "", | ||
"nonce" : "0x00", | ||
"storage" : { | ||
} | ||
}, | ||
"0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" : { | ||
"balance" : "0x174876e800", | ||
"code" : "0x0061736d0100000001110360047f7f7f7f017f60027f7f00600000022b0208657468657265756d06637265617465000008657468657265756d0c73746f7261676553746f72650001030201020503010001071102066d656d6f72790200046d61696e00020a42014001077f410021004120210141c000210241e00021034180012104418002210541d30021062003200420052006200110003602002000200110012002200310010b0ba501030041000b2000000000000000000000000000000000000000000000000000000000000000000041c0000b200000000000000000000000000000000000000000000000000000000000000001004180020b530061736d0100000001090260027f7f0060000002130108657468657265756d0666696e6973680000030201010503010001071102066d656d6f72790200046d61696e00010801010a0a0108004100410010000b", | ||
"nonce" : "0x00", | ||
"storage" : { | ||
} | ||
} | ||
}, | ||
"transaction" : { | ||
"data" : [ | ||
"0x" | ||
], | ||
"gasLimit" : [ | ||
"0x5000001" | ||
], | ||
"gasPrice" : "0x01", | ||
"nonce" : "0x00", | ||
"secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", | ||
"to" : "0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd", | ||
"value" : [ | ||
"0x00" | ||
] | ||
} | ||
} | ||
} |
130 changes: 130 additions & 0 deletions
130
src/GeneralStateTestsFiller/stEWASMTests/initMalformedBytecodeNoMainFiller.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# Test malformed bytecode (no main) in init on create | ||
initMalformedBytecodeNoMain: | ||
env: | ||
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba | ||
currentDifficulty: '0x020000' | ||
currentGasLimit: '89128960' | ||
currentNumber: '1' | ||
currentTimestamp: '1000' | ||
previousHash: 5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6 | ||
pre: | ||
# tx sender | ||
a94f5374fce5edbc8e2a8697c15331677e6ebf0b: | ||
balance: '100000000000' | ||
code: '' | ||
nonce: '' | ||
storage: {} | ||
# WASM source for compiled code, below: | ||
# a000000000000000000000000000000000000001: | ||
# balance: '0' | ||
# nonce: '' | ||
# storage: {} | ||
# code: | | ||
# (module | ||
# (import "ethereum" "finish" (func $finish (param i32 i32))) | ||
# (memory 1) | ||
# (export "memory" (memory 0)) | ||
# (export "main" (func $main)) | ||
|
||
# ;; this start section leads to malformed bytecode | ||
# (start $main) | ||
|
||
# (func $main | ||
# (call $finish | ||
# (i32.const 0) | ||
# (i32.const 0) | ||
# ) | ||
# ) | ||
# ) | ||
# main contract, tx receiver | ||
abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd: | ||
balance: '100000000000' | ||
code: | | ||
(module | ||
(import "ethereum" "create" (func $create (param i32 i32 i32 i32) (result i32))) | ||
(import "ethereum" "storageStore" (func $storageStore (param i32 i32))) | ||
(memory 1) | ||
;; the inner contract to create | ||
;; see WASM source for compiled code, above | ||
(data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") ;; key1 | ||
(data (i32.const 64) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01") ;; key2 | ||
(data (i32.const 256) "\00\61\73\6d\01\00\00\00\01\09\02\60\02\7f\7f\00\60\00\00\02\13\01\08\65\74\68\65\72\65\75\6d\06\66\69\6e\69\73\68\00\00\03\02\01\01\05\03\01\00\01\07\11\02\06\6d\65\6d\6f\72\79\02\00\04\6d\61\69\6e\00\01\08\01\01\0a\0a\01\08\00\41\00\41\00\10\00\0b") ;; init code | ||
(export "memory" (memory 0)) | ||
(export "main" (func $main)) | ||
(func $main | ||
;; memory layout | ||
(local $memStoragekey1 i32) | ||
(local $memStorageval1 i32) | ||
(local $memStoragekey2 i32) | ||
(local $memStorageval2 i32) | ||
(local $memValue i32) | ||
(local $memCode i32) | ||
(local $codeLen i32) | ||
(set_local $memStoragekey1 (i32.const 0)) | ||
(set_local $memStorageval1 (i32.const 32)) | ||
(set_local $memStoragekey2 (i32.const 64)) | ||
(set_local $memStorageval2 (i32.const 96)) | ||
(set_local $memValue (i32.const 128)) | ||
(set_local $memCode (i32.const 256)) | ||
(set_local $codeLen (i32.const 83)) | ||
;; we expect this to fail | ||
(i32.store | ||
(get_local $memStorageval2) | ||
(call $create | ||
;; value offset | ||
(get_local $memValue) | ||
;; data offset | ||
(get_local $memCode) | ||
;; data length | ||
(get_local $codeLen) | ||
;; result offset (new contract address) | ||
(get_local $memStorageval1) | ||
) | ||
) | ||
;; store the result (new contract address) | ||
(call $storageStore | ||
(get_local $memStoragekey1) | ||
(get_local $memStorageval1) | ||
) | ||
;; store the result of the CREATE | ||
(call $storageStore | ||
(get_local $memStoragekey2) | ||
(get_local $memStorageval2) | ||
) | ||
) | ||
) | ||
nonce: '' | ||
storage: {} | ||
expect: | ||
- indexes: | ||
data: !!int -1 | ||
gas: !!int -1 | ||
value: !!int -1 | ||
network: | ||
- ALL | ||
result: | ||
a94f5374fce5edbc8e2a8697c15331677e6ebf0b: | ||
balance: '99917398810' | ||
abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd: | ||
# expect CREATE to return 1 (failure), and no created contract address | ||
storage: { | ||
0: '', | ||
1: '0x0100000000000000000000000000000000000000000000000000000000000000', | ||
} | ||
transaction: | ||
data: | ||
- '' | ||
gasLimit: | ||
- '0x5000001' | ||
gasPrice: '0x01' | ||
nonce: '0x00' | ||
secretKey: 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8 | ||
to: 'abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd' | ||
value: | ||
- '0' |