Skip to content

Commit b6d1724

Browse files
committed
Merge pull request #730 from Gustav-Simonsson/update_transaction_tests
Update transaction tests
2 parents 2053780 + c617a6e commit b6d1724

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4230
-248
lines changed

tests/blocktest.go

+22-24
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ func mustConvertHeader(in btHeader) *types.Header {
187187
UncleHash: mustConvertHash(in.UncleHash),
188188
ParentHash: mustConvertHash(in.ParentHash),
189189
Extra: mustConvertBytes(in.ExtraData),
190-
GasUsed: mustConvertBigInt10(in.GasUsed),
191-
GasLimit: mustConvertBigInt10(in.GasLimit),
192-
Difficulty: mustConvertBigInt10(in.Difficulty),
190+
GasUsed: mustConvertBigInt(in.GasUsed),
191+
GasLimit: mustConvertBigInt(in.GasLimit),
192+
Difficulty: mustConvertBigInt(in.Difficulty),
193193
Time: mustConvertUint(in.Timestamp),
194194
}
195195
// XXX cheats? :-)
@@ -211,9 +211,13 @@ func mustConvertBlocks(testBlocks []btBlock) []*types.Block {
211211
}
212212

213213
func mustConvertBytes(in string) []byte {
214-
out, err := hex.DecodeString(strings.TrimPrefix(in, "0x"))
214+
if in == "0x" {
215+
return []byte{}
216+
}
217+
h := strings.TrimPrefix(unfuckCPPHexInts(in), "0x")
218+
out, err := hex.DecodeString(h)
215219
if err != nil {
216-
panic(fmt.Errorf("invalid hex: %q", in))
220+
panic(fmt.Errorf("invalid hex: %q", h))
217221
}
218222
return out
219223
}
@@ -242,32 +246,16 @@ func mustConvertBloom(in string) types.Bloom {
242246
return types.BytesToBloom(out)
243247
}
244248

245-
func mustConvertBigInt10(in string) *big.Int {
246-
out, ok := new(big.Int).SetString(in, 10)
247-
if !ok {
248-
panic(fmt.Errorf("invalid integer: %q", in))
249-
}
250-
return out
251-
}
252-
253-
func mustConvertBigIntHex(in string) *big.Int {
254-
out, ok := new(big.Int).SetString(in, 16)
249+
func mustConvertBigInt(in string) *big.Int {
250+
out, ok := new(big.Int).SetString(unfuckCPPHexInts(in), 0)
255251
if !ok {
256252
panic(fmt.Errorf("invalid integer: %q", in))
257253
}
258254
return out
259255
}
260256

261257
func mustConvertUint(in string) uint64 {
262-
out, err := strconv.ParseUint(in, 0, 64)
263-
if err != nil {
264-
panic(fmt.Errorf("invalid integer: %q", in))
265-
}
266-
return out
267-
}
268-
269-
func mustConvertUintHex(in string) uint64 {
270-
out, err := strconv.ParseUint(in, 16, 64)
258+
out, err := strconv.ParseUint(unfuckCPPHexInts(in), 0, 64)
271259
if err != nil {
272260
panic(fmt.Errorf("invalid integer: %q", in))
273261
}
@@ -303,3 +291,13 @@ func findLine(data []byte, offset int64) (line int) {
303291
}
304292
return
305293
}
294+
295+
func unfuckCPPHexInts(s string) string {
296+
if s == "0x" { // no respect for the empty value :(
297+
return "0x00"
298+
}
299+
if (len(s) % 2) != 0 { // motherfucking nibbles
300+
return "0x0" + s[2:]
301+
}
302+
return s
303+
}

tests/files/BlockTests/bcForkBlockTest.json

+367
Large diffs are not rendered by default.

tests/files/BlockTests/bcInvalidRLPTest.json

+26-26
Large diffs are not rendered by default.

tests/files/BlockTests/bcRPC_API_Test.json

+1,257
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"randomStatetest" : {
3+
"env" : {
4+
"currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
5+
"currentDifficulty" : "5623894562375",
6+
"currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
7+
"currentNumber" : "0",
8+
"currentTimestamp" : "1",
9+
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
10+
},
11+
"logs" : [
12+
],
13+
"out" : "0x",
14+
"post" : {
15+
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
16+
"balance" : "0",
17+
"code" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000100000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f0000000000000000000000000000000000000000000000000000000000000001c9206e3b8f9d858f438a",
18+
"nonce" : "0",
19+
"storage" : {
20+
}
21+
},
22+
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
23+
"balance" : "1582728260",
24+
"code" : "0x6000355415600957005b60203560003555",
25+
"nonce" : "0",
26+
"storage" : {
27+
}
28+
},
29+
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
30+
"balance" : "999999998417271786",
31+
"code" : "0x",
32+
"nonce" : "1",
33+
"storage" : {
34+
}
35+
}
36+
},
37+
"postStateRoot" : "cbcd9800020c801c45de04da2bd7697b9fd44d571860a7555ebc61ba44ae11af",
38+
"pre" : {
39+
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
40+
"balance" : "0",
41+
"code" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000100000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f0000000000000000000000000000000000000000000000000000000000000001c9206e3b8f9d858f438a",
42+
"nonce" : "0",
43+
"storage" : {
44+
}
45+
},
46+
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
47+
"balance" : "46",
48+
"code" : "0x6000355415600957005b60203560003555",
49+
"nonce" : "0",
50+
"storage" : {
51+
}
52+
},
53+
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
54+
"balance" : "1000000000000000000",
55+
"code" : "0x",
56+
"nonce" : "0",
57+
"storage" : {
58+
}
59+
}
60+
},
61+
"transaction" : {
62+
"data" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000100000000000000000000000000000000000000007f00000000000000000000000100000000000000000000000000000000000000007f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f0000000000000000000000000000000000000000000000000000000000000001c9206e3b8f9d858f438a",
63+
"gasLimit" : "0x5e568416",
64+
"gasPrice" : "1",
65+
"nonce" : "0",
66+
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
67+
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
68+
"value" : "1174580620"
69+
}
70+
}
71+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"randomStatetest" : {
3+
"env" : {
4+
"currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
5+
"currentDifficulty" : "5623894562375",
6+
"currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
7+
"currentNumber" : "0",
8+
"currentTimestamp" : "1",
9+
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
10+
},
11+
"logs" : [
12+
],
13+
"out" : "0x",
14+
"post" : {
15+
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
16+
"balance" : "1384582119",
17+
"code" : "0x7f0000000000000000000000000000000000000000000000000000000000000000457fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff3b6f88a3615234423703758c55",
18+
"nonce" : "0",
19+
"storage" : {
20+
}
21+
},
22+
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
23+
"balance" : "30725",
24+
"code" : "0x6000355415600957005b60203560003555",
25+
"nonce" : "0",
26+
"storage" : {
27+
}
28+
},
29+
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
30+
"balance" : "999999998615387202",
31+
"code" : "0x",
32+
"nonce" : "1",
33+
"storage" : {
34+
}
35+
}
36+
},
37+
"postStateRoot" : "9bfe791ae77437f94a9768f5ba5ae336dad7eeab155897b8a8ea8a5445f50d9e",
38+
"pre" : {
39+
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
40+
"balance" : "0",
41+
"code" : "0x7f0000000000000000000000000000000000000000000000000000000000000000457fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff3b6f88a3615234423703758c55",
42+
"nonce" : "0",
43+
"storage" : {
44+
}
45+
},
46+
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
47+
"balance" : "46",
48+
"code" : "0x6000355415600957005b60203560003555",
49+
"nonce" : "0",
50+
"storage" : {
51+
}
52+
},
53+
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
54+
"balance" : "1000000000000000000",
55+
"code" : "0x",
56+
"nonce" : "0",
57+
"storage" : {
58+
}
59+
}
60+
},
61+
"transaction" : {
62+
"data" : "0x7f0000000000000000000000000000000000000000000000000000000000000000457fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff3b6f88a3615234423703758c",
63+
"gasLimit" : "0x10730dc2",
64+
"gasPrice" : "1",
65+
"nonce" : "0",
66+
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
67+
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
68+
"value" : "1384582119"
69+
}
70+
}
71+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"randomStatetest" : {
3+
"env" : {
4+
"currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
5+
"currentDifficulty" : "5623894562375",
6+
"currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
7+
"currentNumber" : "0",
8+
"currentTimestamp" : "1",
9+
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
10+
},
11+
"logs" : [
12+
],
13+
"out" : "0x",
14+
"post" : {
15+
"00000000427fffffffffffffffffffffffffffff" : {
16+
"balance" : "211829998",
17+
"code" : "0x",
18+
"nonce" : "0",
19+
"storage" : {
20+
}
21+
},
22+
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
23+
"balance" : "15653",
24+
"code" : "0x6000355415600957005b60203560003555",
25+
"nonce" : "0",
26+
"storage" : {
27+
}
28+
},
29+
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
30+
"balance" : "999999999788154395",
31+
"code" : "0x",
32+
"nonce" : "1",
33+
"storage" : {
34+
}
35+
}
36+
},
37+
"postStateRoot" : "4b0266280765370fc26f2ecee50a128fcc7d1ff0e578ce684a43f546fabf41ad",
38+
"pre" : {
39+
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
40+
"balance" : "0",
41+
"code" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f00000000000000000000000100000000000000000000000000000000000000006f427ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7e6410f26f519c538ea2070a6c60005155",
42+
"nonce" : "0",
43+
"storage" : {
44+
}
45+
},
46+
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
47+
"balance" : "46",
48+
"code" : "0x6000355415600957005b60203560003555",
49+
"nonce" : "0",
50+
"storage" : {
51+
}
52+
},
53+
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
54+
"balance" : "1000000000000000000",
55+
"code" : "0x",
56+
"nonce" : "0",
57+
"storage" : {
58+
}
59+
}
60+
},
61+
"transaction" : {
62+
"data" : "0x7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f00000000000000000000000100000000000000000000000000000000000000006f427ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7e6410f26f519c538ea2070a6c",
63+
"gasLimit" : "0x2c138ff5",
64+
"gasPrice" : "1",
65+
"nonce" : "0",
66+
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
67+
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
68+
"value" : "211829998"
69+
}
70+
}
71+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"randomStatetest" : {
3+
"env" : {
4+
"currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
5+
"currentDifficulty" : "5623894562375",
6+
"currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
7+
"currentNumber" : "0",
8+
"currentTimestamp" : "1",
9+
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
10+
},
11+
"logs" : [
12+
],
13+
"out" : "0x",
14+
"post" : {
15+
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
16+
"balance" : "108687806",
17+
"code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6a7f0000000000000000000000000000000000000000000000000000000000000000907f00000000000000000000000000000000000000000000000000000000000000017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff906606425655",
18+
"nonce" : "0",
19+
"storage" : {
20+
}
21+
},
22+
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
23+
"balance" : "30960",
24+
"code" : "0x6000355415600957005b60203560003555",
25+
"nonce" : "0",
26+
"storage" : {
27+
}
28+
},
29+
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
30+
"balance" : "999999999891281280",
31+
"code" : "0x",
32+
"nonce" : "1",
33+
"storage" : {
34+
}
35+
}
36+
},
37+
"postStateRoot" : "e8dbd20c0ca9c7daab8dc415e43f312f4fcd38b250500f7b66ba86ae5b7270a6",
38+
"pre" : {
39+
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
40+
"balance" : "0",
41+
"code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6a7f0000000000000000000000000000000000000000000000000000000000000000907f00000000000000000000000000000000000000000000000000000000000000017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff906606425655",
42+
"nonce" : "0",
43+
"storage" : {
44+
}
45+
},
46+
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
47+
"balance" : "46",
48+
"code" : "0x6000355415600957005b60203560003555",
49+
"nonce" : "0",
50+
"storage" : {
51+
}
52+
},
53+
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
54+
"balance" : "1000000000000000000",
55+
"code" : "0x",
56+
"nonce" : "0",
57+
"storage" : {
58+
}
59+
}
60+
},
61+
"transaction" : {
62+
"data" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6a7f0000000000000000000000000000000000000000000000000000000000000000907f00000000000000000000000000000000000000000000000000000000000000017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9066064256",
63+
"gasLimit" : "0x2ab6153e",
64+
"gasPrice" : "1",
65+
"nonce" : "0",
66+
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
67+
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
68+
"value" : "108687806"
69+
}
70+
}
71+
}

0 commit comments

Comments
 (0)