diff --git a/tests/block_test.go b/tests/block_test.go deleted file mode 100644 index 3c2288dbdc..0000000000 --- a/tests/block_test.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "testing" -) - -func TestBlockchain(t *testing.T) { - t.Parallel() - - bt := new(testMatcher) - // General state tests are 'exported' as blockchain tests, but we can run them natively. - // For speedier CI-runs, the line below can be uncommented, so those are skipped. - // For now, in hardfork-times we run the tests both as StateTests and - // as blockchain tests, since the latter also covers things like receipt root - bt.skipLoad(`^GeneralStateTests/`) - - // Skip random failures due to selfish mining test - bt.skipLoad(`.*bcForgedTest/bcForkUncle\.json`) - - // Slow tests - bt.slow(`.*bcExploitTest/DelegateCallSpam.json`) - bt.slow(`.*bcExploitTest/ShanghaiLove.json`) - bt.slow(`.*bcExploitTest/SuicideIssue.json`) - bt.slow(`.*/bcForkStressTest/`) - bt.slow(`.*/bcGasPricerTest/RPC_API_Test.json`) - bt.slow(`.*/bcWalletTest/`) - - // Very slow test - bt.skipLoad(`.*/stTimeConsuming/.*`) - // test takes a lot for time and goes easily OOM because of sha3 calculation on a huge range, - // using 4.6 TGas - bt.skipLoad(`.*randomStatetest94.json.*`) - bt.walk(t, blockTestDir, func(t *testing.T, name string, test *BlockTest) { - if err := bt.checkFailure(t, test.Run(false)); err != nil { - t.Errorf("test without snapshotter failed: %v", err) - } - if err := bt.checkFailure(t, test.Run(true)); err != nil { - t.Errorf("test with snapshotter failed: %v", err) - } - }) -} diff --git a/tests/block_test_util.go b/tests/block_test_util.go deleted file mode 100644 index a9d542bcdb..0000000000 --- a/tests/block_test_util.go +++ /dev/null @@ -1,317 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -// Package tests implements execution of Quai JSON tests. -package tests - -import ( - "bytes" - "encoding/hex" - "encoding/json" - "fmt" - "math/big" - "os" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/common/hexutil" - "github.com/dominant-strategies/go-quai/common/math" - "github.com/dominant-strategies/go-quai/consensus" - "github.com/dominant-strategies/go-quai/consensus/progpow" - "github.com/dominant-strategies/go-quai/core" - "github.com/dominant-strategies/go-quai/core/rawdb" - "github.com/dominant-strategies/go-quai/core/state" - "github.com/dominant-strategies/go-quai/core/types" - "github.com/dominant-strategies/go-quai/core/vm" - "github.com/dominant-strategies/go-quai/params" - "github.com/dominant-strategies/go-quai/rlp" -) - -// A BlockTest checks handling of entire blocks. -type BlockTest struct { - json btJSON -} - -// UnmarshalJSON implements json.Unmarshaler interface. -func (t *BlockTest) UnmarshalJSON(in []byte) error { - return json.Unmarshal(in, &t.json) -} - -type btJSON struct { - Blocks []btBlock `json:"blocks"` - Genesis btHeader `json:"genesisBlockHeader"` - Pre core.GenesisAlloc `json:"pre"` - Post core.GenesisAlloc `json:"postState"` - BestBlock common.UnprefixedHash `json:"lastblockhash"` - Network string `json:"network"` - SealEngine string `json:"sealEngine"` -} - -type btBlock struct { - BlockHeader *btHeader - ExpectException string - Rlp string - UncleHeaders []*btHeader -} - -//go:generate gencodec -type btHeader -field-override btHeaderMarshaling -out gen_btheader.go - -type btHeader struct { - Bloom types.Bloom - Coinbase common.Address - MixHash common.Hash - Nonce types.BlockNonce - Number *big.Int - Hash common.Hash - ParentHash common.Hash - ReceiptTrie common.Hash - StateRoot common.Hash - TransactionsTrie common.Hash - UncleHash common.Hash - ExtraData []byte - Difficulty *big.Int - GasLimit uint64 - GasUsed uint64 - Timestamp uint64 - BaseFeePerGas *big.Int -} - -type btHeaderMarshaling struct { - ExtraData hexutil.Bytes - Number *math.HexOrDecimal256 - Difficulty *math.HexOrDecimal256 - GasLimit math.HexOrDecimal64 - GasUsed math.HexOrDecimal64 - Timestamp math.HexOrDecimal64 - BaseFeePerGas *math.HexOrDecimal256 -} - -func (t *BlockTest) Run(snapshotter bool) error { - config, ok := Forks[t.json.Network] - if !ok { - return UnsupportedForkError{t.json.Network} - } - - // import pre accounts & construct test genesis block & state root - db := rawdb.NewMemoryDatabase() - gblock, err := t.genesis(config).Commit(db) - if err != nil { - return err - } - if gblock.Hash() != t.json.Genesis.Hash { - return fmt.Errorf("genesis block hash doesn't match test: computed=%x, test=%x", gblock.Hash().Bytes()[:6], t.json.Genesis.Hash[:6]) - } - if gblock.Root() != t.json.Genesis.StateRoot { - return fmt.Errorf("genesis block state root does not match test: computed=%x, test=%x", gblock.Root().Bytes()[:6], t.json.Genesis.StateRoot[:6]) - } - var engine consensus.Engine - if t.json.SealEngine == "NoProof" { - engine = progpow.NewFaker() - } else { - engine = progpow.NewShared() - } - cache := &core.CacheConfig{TrieCleanLimit: 0} - if snapshotter { - cache.SnapshotLimit = 1 - } - chain, err := core.NewBlockChain(db, cache, config, engine, vm.Config{}, nil, nil) - if err != nil { - return err - } - defer chain.Stop() - - validBlocks, err := t.insertBlocks(chain) - if err != nil { - return err - } - cmlast := chain.CurrentBlock().Hash() - if common.Hash(t.json.BestBlock) != cmlast { - return fmt.Errorf("last block hash validation mismatch: want: %x, have: %x", t.json.BestBlock, cmlast) - } - newDB, err := chain.State() - if err != nil { - return err - } - if err = t.validatePostState(newDB); err != nil { - return fmt.Errorf("post state validation failed: %v", err) - } - // Cross-check the snapshot-to-hash against the trie hash - if snapshotter { - if err := chain.Snapshots().Verify(chain.CurrentBlock().Root()); err != nil { - return err - } - } - return t.validateImportedHeaders(chain, validBlocks) -} - -func (t *BlockTest) genesis(config *params.ChainConfig) *core.Genesis { - return &core.Genesis{ - Config: config, - Nonce: t.json.Genesis.Nonce().Uint64(), - Timestamp: t.json.Genesis.Timestamp, - ParentHash: t.json.Genesis.ParentHash(), - ExtraData: t.json.Genesis.ExtraData, - GasLimit: t.json.Genesis.GasLimit(), - GasUsed: t.json.Genesis.GasUsed(), - Difficulty: t.json.Genesis.Difficulty(), - Mixhash: t.json.Genesis.MixHash, - Coinbase: t.json.Genesis.Coinbase(), - Alloc: t.json.Pre, - BaseFee: t.json.Genesis.BaseFeePerGas, - } -} - -/* -Whether a block is valid or not is a bit subtle, it's defined by presence of -blockHeader, transactions and uncleHeaders fields. If they are missing, the block is -invalid and we must verify that we do not accept it. - -Since some tests mix valid and invalid blocks we need to check this for every block. - -If a block is invalid it does not necessarily fail the test, if it's invalidness is -expected we are expected to ignore it and continue processing and then validate the -post state. -*/ -func (t *BlockTest) insertBlocks(blockchain *core.BlockChain) ([]btBlock, error) { - validBlocks := make([]btBlock, 0) - // insert the test blocks, which will execute all transactions - for bi, b := range t.json.Blocks { - cb, err := b.decode() - if err != nil { - if b.BlockHeader == nil { - continue // OK - block is supposed to be invalid, continue with next block - } else { - return nil, fmt.Errorf("block RLP decoding failed when expected to succeed: %v", err) - } - } - // RLP decoding worked, try to insert into chain: - blocks := types.Blocks{cb} - i, err := blockchain.InsertChain(blocks) - if err != nil { - if b.BlockHeader == nil { - continue // OK - block is supposed to be invalid, continue with next block - } else { - return nil, fmt.Errorf("block #%v insertion into chain failed: %v", blocks[i].Number(), err) - } - } - if b.BlockHeader == nil { - if data, err := json.MarshalIndent(cb.Header(), "", " "); err == nil { - fmt.Fprintf(os.Stderr, "block (index %d) insertion should have failed due to: %v:\n%v\n", - bi, b.ExpectException, string(data)) - } - return nil, fmt.Errorf("block (index %d) insertion should have failed due to: %v", - bi, b.ExpectException) - } - - // validate RLP decoding by checking all values against test file JSON - if err = validateHeader(b.BlockHeader, cb.Header()); err != nil { - return nil, fmt.Errorf("deserialised block header validation failed: %v", err) - } - validBlocks = append(validBlocks, b) - } - return validBlocks, nil -} - -func validateHeader(h *btHeader, h2 *types.Header) error { - if h.Coinbase() != h2.Coinbase() { - return fmt.Errorf("coinbase: want: %x have: %x", h.Coinbase(), h2.Coinbase()) - } - if h.Nonce() != h2.Nonce() { - return fmt.Errorf("nonce: want: %x have: %x", h.Nonce(), h2.Nonce()) - } - if h.Number().Cmp(h2.Number()) != 0 { - return fmt.Errorf("number: want: %v have: %v", h.Number(), h2.Number()) - } - if h.ParentHash() != h2.ParentHash() { - return fmt.Errorf("parent hash: want: %x have: %x", h.ParentHash(), h2.ParentHash()) - } - if h.ReceiptTrie != h2.ReceiptHash() { - return fmt.Errorf("receipt hash: want: %x have: %x", h.ReceiptTrie, h2.ReceiptHash()) - } - if h.TransactionsTrie != h2.TxHash() { - return fmt.Errorf("tx hash: want: %x have: %x", h.TransactionsTrie, h2.TxHash()) - } - if h.StateRoot != h2.Root() { - return fmt.Errorf("state hash: want: %x have: %x", h.StateRoot, h2.Root()) - } - if h.UncleHash() != h2.UncleHash() { - return fmt.Errorf("uncle hash: want: %x have: %x", h.UncleHash(), h2.UncleHash()) - } - if !bytes.Equal(h.ExtraData, h2.Extra()) { - return fmt.Errorf("extra data: want: %x have: %x", h.ExtraData, h2.Extra()) - } - if h.Difficulty().Cmp(h2.Difficulty()) != 0 { - return fmt.Errorf("difficulty: want: %v have: %v", h.Difficulty(), h2.Difficulty()) - } - if h.GasLimit() != h2.GasLimit() { - return fmt.Errorf("gasLimit: want: %d have: %d", h.GasLimit(), h2.GasLimit()) - } - if h.GasUsed() != h2.GasUsed() { - return fmt.Errorf("gasUsed: want: %d have: %d", h.GasUsed(), h2.GasUsed()) - } - if h.Timestamp != h2.Time() { - return fmt.Errorf("timestamp: want: %v have: %v", h.Timestamp, h2.Time()) - } - return nil -} - -func (t *BlockTest) validatePostState(statedb *state.StateDB) error { - // validate post state accounts in test file against what we have in state db - for addr, acct := range t.json.Post { - // address is indirectly verified by the other fields, as it's the db key - code2 := statedb.GetCode(addr) - balance2 := statedb.GetBalance(addr) - nonce2 := statedb.GetNonce(addr) - if !bytes.Equal(code2, acct.Code) { - return fmt.Errorf("account code mismatch for addr: %s want: %v have: %s", addr, acct.Code, hex.EncodeToString(code2)) - } - if balance2.Cmp(acct.Balance) != 0 { - return fmt.Errorf("account balance mismatch for addr: %s, want: %d, have: %d", addr, acct.Balance, balance2) - } - if nonce2 != acct.Nonce() { - return fmt.Errorf("account nonce mismatch for addr: %s want: %d have: %d", addr, acct.Nonce(), nonce2) - } - } - return nil -} - -func (t *BlockTest) validateImportedHeaders(cm *core.BlockChain, validBlocks []btBlock) error { - // to get constant lookup when verifying block headers by hash (some tests have many blocks) - bmap := make(map[common.Hash]btBlock, len(t.json.Blocks)) - for _, b := range validBlocks { - bmap[b.BlockHeader.Hash] = b - } - // iterate over blocks backwards from HEAD and validate imported - // headers vs test file. some tests have reorgs, and we import - // block-by-block, so we can only validate imported headers after - // all blocks have been processed by BlockChain, as they may not - // be part of the longest chain until last block is imported. - for b := cm.CurrentBlock(); b != nil && b.NumberU64() != 0; b = cm.GetBlockByHash(b.Header().ParentHash()) { - if err := validateHeader(bmap[b.Hash()].BlockHeader, b.Header()); err != nil { - return fmt.Errorf("imported block header validation failed: %v", err) - } - } - return nil -} - -func (bb *btBlock) decode() (*types.Block, error) { - data, err := hexutil.Decode(bb.Rlp) - if err != nil { - return nil, err - } - var b types.Block - err = rlp.DecodeBytes(data, &b) - return &b, err -} diff --git a/tests/difficulty_test.go b/tests/difficulty_test.go deleted file mode 100644 index 50d3deb31e..0000000000 --- a/tests/difficulty_test.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "math/big" - "testing" - - "github.com/dominant-strategies/go-quai/params" -) - -var ( - mainnetChainConfig = params.ChainConfig{ - ChainID: big.NewInt(1), - } -) - -func TestDifficulty(t *testing.T) { - t.Parallel() - - dt := new(testMatcher) - // Not difficulty-tests - dt.skipLoad("hexencodetest.*") - dt.skipLoad("crypto.*") - dt.skipLoad("blockgenesistest\\.json") - dt.skipLoad("genesishashestest\\.json") - dt.skipLoad("keyaddrtest\\.json") - dt.skipLoad("txtest\\.json") - - // files are 2 years old, contains strange values - dt.skipLoad("difficultyMorden\\.json") - dt.skipLoad("difficultyOlimpic\\.json") - - dt.config("Garden", *params.GardenChainConfig) - dt.config("Morden", *params.GardenChainConfig) - - dt.config("MainNetwork", mainnetChainConfig) - dt.config("CustomMainNetwork", mainnetChainConfig) - dt.config("difficulty.json", mainnetChainConfig) - - dt.walk(t, difficultyTestDir, func(t *testing.T, name string, test *DifficultyTest) { - cfg := dt.findConfig(t) - if test.ParentDifficulty.Cmp(params.MinimumDifficulty) < 0 { - t.Skip("difficulty below minimum") - return - } - if err := dt.checkFailure(t, test.Run(cfg)); err != nil { - t.Error(err) - } - }) -} diff --git a/tests/difficulty_test_util.go b/tests/difficulty_test_util.go deleted file mode 100644 index 87199fc436..0000000000 --- a/tests/difficulty_test_util.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "fmt" - "math/big" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/common/math" - "github.com/dominant-strategies/go-quai/consensus/progpow" - "github.com/dominant-strategies/go-quai/core/types" - "github.com/dominant-strategies/go-quai/params" -) - -//go:generate gencodec -type DifficultyTest -field-override difficultyTestMarshaling -out gen_difficultytest.go - -type DifficultyTest struct { - ParentTimestamp uint64 `json:"parentTimestamp"` - ParentDifficulty *big.Int `json:"parentDifficulty"` - UncleHash common.Hash `json:"parentUncles"` - CurrentTimestamp uint64 `json:"currentTimestamp"` - CurrentBlockNumber uint64 `json:"currentBlockNumber"` - CurrentDifficulty *big.Int `json:"currentDifficulty"` -} - -type difficultyTestMarshaling struct { - ParentTimestamp math.HexOrDecimal64 - ParentDifficulty *math.HexOrDecimal256 - CurrentTimestamp math.HexOrDecimal64 - CurrentDifficulty *math.HexOrDecimal256 - UncleHash common.Hash - CurrentBlockNumber math.HexOrDecimal64 -} - -func (test *DifficultyTest) Run(config *params.ChainConfig) error { - parentNumber := big.NewInt(int64(test.CurrentBlockNumber - 1)) - parent := &types.Header{ - Difficulty: test.ParentDifficulty, - Time: test.ParentTimestamp, - Number: parentNumber, - UncleHash: test.UncleHash(), - } - - actual := progpow.CalcDifficulty(config, test.CurrentTimestamp, parent) - exp := test.CurrentDifficulty - - if actual.Cmp(exp) != 0 { - return fmt.Errorf("parent[time %v diff %v unclehash:%x] child[time %v number %v] diff %v != expected %v", - test.ParentTimestamp, test.ParentDifficulty, test.UncleHash(), - test.CurrentTimestamp, test.CurrentBlockNumber, actual, exp) - } - return nil - -} diff --git a/tests/fuzzers/README.md b/tests/fuzzers/README.md deleted file mode 100644 index 7611c53698..0000000000 --- a/tests/fuzzers/README.md +++ /dev/null @@ -1,45 +0,0 @@ -## Fuzzers - -To run a fuzzer locally, you need [go-fuzz](https://github.com/dvyukov/go-fuzz) installed. - -First build a fuzzing-binary out of the selected package: - -``` -(cd ./rlp && CGO_ENABLED=0 go-fuzz-build .) -``` -That command should generate a `rlp-fuzz.zip` in the `rlp/` directory. If you are already in that directory, you can do - -``` -[user@work rlp]$ go-fuzz -2019/11/26 13:36:54 workers: 6, corpus: 3 (3s ago), crashers: 0, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 3s -2019/11/26 13:36:57 workers: 6, corpus: 3 (6s ago), crashers: 0, restarts: 1/0, execs: 0 (0/sec), cover: 1054, uptime: 6s -2019/11/26 13:37:00 workers: 6, corpus: 3 (9s ago), crashers: 0, restarts: 1/8358, execs: 25074 (2786/sec), cover: 1054, uptime: 9s -2019/11/26 13:37:03 workers: 6, corpus: 3 (12s ago), crashers: 0, restarts: 1/8497, execs: 50986 (4249/sec), cover: 1054, uptime: 12s -2019/11/26 13:37:06 workers: 6, corpus: 3 (15s ago), crashers: 0, restarts: 1/9330, execs: 74640 (4976/sec), cover: 1054, uptime: 15s -2019/11/26 13:37:09 workers: 6, corpus: 3 (18s ago), crashers: 0, restarts: 1/9948, execs: 99482 (5527/sec), cover: 1054, uptime: 18s -2019/11/26 13:37:12 workers: 6, corpus: 3 (21s ago), crashers: 0, restarts: 1/9428, execs: 122568 (5836/sec), cover: 1054, uptime: 21s -2019/11/26 13:37:15 workers: 6, corpus: 3 (24s ago), crashers: 0, restarts: 1/9676, execs: 145152 (6048/sec), cover: 1054, uptime: 24s -2019/11/26 13:37:18 workers: 6, corpus: 3 (27s ago), crashers: 0, restarts: 1/9855, execs: 167538 (6205/sec), cover: 1054, uptime: 27s -2019/11/26 13:37:21 workers: 6, corpus: 3 (30s ago), crashers: 0, restarts: 1/9645, execs: 192901 (6430/sec), cover: 1054, uptime: 30s -2019/11/26 13:37:24 workers: 6, corpus: 3 (33s ago), crashers: 0, restarts: 1/9967, execs: 219294 (6645/sec), cover: 1054, uptime: 33s - -``` -Otherwise: -``` -go-fuzz -bin ./rlp/rlp-fuzz.zip -``` - -### Notes - -Once a 'crasher' is found, the fuzzer tries to avoid reporting the same vector twice, so stores the fault in the `suppressions` folder. Thus, if you -e.g. make changes to fix a bug, you should _remove_ all data from the `suppressions`-folder, to verify that the issue is indeed resolved. - -Also, if you have only one and the same exit-point for multiple different types of test, the suppression can make the fuzzer hide different types of errors. So make -sure that each type of failure is unique (for an example, see the rlp fuzzer, where a counter `i` is used to differentiate between failures: - -```golang - if !bytes.Equal(input, output) { - panic(fmt.Sprintf("case %d: encode-decode is not equal, \ninput : %x\noutput: %x", i, input, output)) - } -``` - diff --git a/tests/fuzzers/bitutil/compress_fuzz.go b/tests/fuzzers/bitutil/compress_fuzz.go deleted file mode 100644 index 2ff23fb3d2..0000000000 --- a/tests/fuzzers/bitutil/compress_fuzz.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package bitutil - -import ( - "bytes" - - "github.com/dominant-strategies/go-quai/common/bitutil" -) - -// Fuzz implements a go-fuzz fuzzer method to test various encoding method -// invocations. -func Fuzz(data []byte) int { - if len(data) == 0 { - return 0 - } - if data[0]%2 == 0 { - return fuzzEncode(data[1:]) - } - return fuzzDecode(data[1:]) -} - -// fuzzEncode implements a go-fuzz fuzzer method to test the bitset encoding and -// decoding algorithm. -func fuzzEncode(data []byte) int { - proc, _ := bitutil.DecompressBytes(bitutil.CompressBytes(data), len(data)) - if !bytes.Equal(data, proc) { - panic("content mismatch") - } - return 1 -} - -// fuzzDecode implements a go-fuzz fuzzer method to test the bit decoding and -// reencoding algorithm. -func fuzzDecode(data []byte) int { - blob, err := bitutil.DecompressBytes(data, 1024) - if err != nil { - return 0 - } - // re-compress it (it's OK if the re-compressed differs from the - // original - the first input may not have been compressed at all) - comp := bitutil.CompressBytes(blob) - if len(comp) > len(blob) { - // After compression, it must be smaller or equal - panic("bad compression") - } - // But decompressing it once again should work - decomp, err := bitutil.DecompressBytes(data, 1024) - if err != nil { - panic(err) - } - if !bytes.Equal(decomp, blob) { - panic("content mismatch") - } - return 1 -} diff --git a/tests/fuzzers/difficulty/debug/main.go b/tests/fuzzers/difficulty/debug/main.go deleted file mode 100644 index 989551725e..0000000000 --- a/tests/fuzzers/difficulty/debug/main.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ( - "fmt" - "io/ioutil" - "os" - - "github.com/dominant-strategies/go-quai/tests/fuzzers/difficulty" -) - -func main() { - if len(os.Args) != 2 { - fmt.Fprintf(os.Stderr, "Usage: debug ") - os.Exit(1) - } - crasher := os.Args[1] - data, err := ioutil.ReadFile(crasher) - if err != nil { - fmt.Fprintf(os.Stderr, "error loading crasher %v: %v", crasher, err) - os.Exit(1) - } - difficulty.Fuzz(data) -} diff --git a/tests/fuzzers/difficulty/difficulty-fuzz.go b/tests/fuzzers/difficulty/difficulty-fuzz.go deleted file mode 100644 index 21bc824848..0000000000 --- a/tests/fuzzers/difficulty/difficulty-fuzz.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2020 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package difficulty - -import ( - "bytes" - "encoding/binary" - "fmt" - "io" - "math/big" - - "github.com/dominant-strategies/go-quai/consensus/progpow" - "github.com/dominant-strategies/go-quai/core/types" -) - -type fuzzer struct { - input io.Reader - exhausted bool - debugging bool -} - -func (f *fuzzer) read(size int) []byte { - out := make([]byte, size) - if _, err := f.input.Read(out); err != nil { - f.exhausted = true - } - return out -} - -func (f *fuzzer) readSlice(min, max int) []byte { - var a uint16 - binary.Read(f.input, binary.LittleEndian, &a) - size := min + int(a)%(max-min) - out := make([]byte, size) - if _, err := f.input.Read(out); err != nil { - f.exhausted = true - } - return out -} - -func (f *fuzzer) readUint64(min, max uint64) uint64 { - if min == max { - return min - } - var a uint64 - if err := binary.Read(f.input, binary.LittleEndian, &a); err != nil { - f.exhausted = true - } - a = min + a%(max-min) - return a -} -func (f *fuzzer) readBool() bool { - return f.read(1)[0]&0x1 == 0 -} - -// The function must return -// 1 if the fuzzer should increase priority of the -// given input during subsequent fuzzing (for example, the input is lexically -// correct and was parsed successfully); -// -1 if the input must not be added to corpus even if gives new coverage; and -// 0 otherwise -// other values are reserved for future use. -func Fuzz(data []byte) int { - f := fuzzer{ - input: bytes.NewReader(data), - exhausted: false, - } - return f.fuzz() -} - -var minDifficulty = big.NewInt(0x2000) - -type calculator func(time uint64, parent *types.Header) *big.Int - -func (f *fuzzer) fuzz() int { - // A parent header - header := types.EmptyHeader() - if f.readBool() { - header.UncleHash() = types.EmptyUncleHash - } - // Difficulty can range between 0x2000 (2 bytes) and up to 32 bytes - { - diff := new(big.Int).SetBytes(f.readSlice(2, 32)) - if diff.Cmp(minDifficulty) < 0 { - diff.Set(minDifficulty) - } - header.Difficulty() = diff - } - // Number can range between 0 and up to 32 bytes (but not so that the child exceeds it) - { - // However, if we use astronomic numbers, then the bomb exp karatsuba calculation - // in the legacy methods) - // times out, so we limit it to fit within reasonable bounds - number := new(big.Int).SetBytes(f.readSlice(0, 4)) // 4 bytes: 32 bits: block num max 4 billion - header.Number() = number - } - // Both parent and child time must fit within uint64 - var time uint64 - { - childTime := f.readUint64(1, 0xFFFFFFFFFFFFFFFF) - //fmt.Printf("childTime: %x\n",childTime) - delta := f.readUint64(1, childTime) - //fmt.Printf("delta: %v\n", delta) - pTime := childTime - delta - header.Time() = pTime - time = childTime - } - // Bomb delay will never exceed uint64 - bombDelay := new(big.Int).SetUint64(f.readUint64(1, 0xFFFFFFFFFFFFFFFe)) - - if f.exhausted { - return 0 - } - - for i, pair := range []struct { - bigFn calculator - u256Fn calculator - }{ - {progpow.DynamicDifficultyCalculator(bombDelay), progpow.MakeDifficultyCalculatorU256(bombDelay)}, - } { - want := pair.bigFn(time, header) - have := pair.u256Fn(time, header) - if want.Cmp(have) != 0 { - panic(fmt.Sprintf("pair %d: want %x have %x\nparent.Number: %x\np.Time: %x\nc.Time: %x\nBombdelay: %v\n", i, want, have, - header.Number(), header.Time(), time, bombDelay)) - } - } - return 1 -} diff --git a/tests/fuzzers/les/debug/main.go b/tests/fuzzers/les/debug/main.go deleted file mode 100644 index efb16b9c6a..0000000000 --- a/tests/fuzzers/les/debug/main.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2020 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package main - -import ( - "fmt" - "io/ioutil" - "os" - - "github.com/dominant-strategies/go-quai/tests/fuzzers/les" -) - -func main() { - if len(os.Args) != 2 { - fmt.Fprintf(os.Stderr, "Usage: debug \n") - fmt.Fprintf(os.Stderr, "Example\n") - fmt.Fprintf(os.Stderr, " $ debug ../crashers/4bbef6857c733a87ecf6fd8b9e7238f65eb9862a\n") - os.Exit(1) - } - crasher := os.Args[1] - data, err := ioutil.ReadFile(crasher) - if err != nil { - fmt.Fprintf(os.Stderr, "error loading crasher %v: %v", crasher, err) - os.Exit(1) - } - les.Fuzz(data) -} diff --git a/tests/fuzzers/les/les-fuzzer.go b/tests/fuzzers/les/les-fuzzer.go deleted file mode 100644 index 123f0e8c4d..0000000000 --- a/tests/fuzzers/les/les-fuzzer.go +++ /dev/null @@ -1,406 +0,0 @@ -// Copyright 2021 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package les - -import ( - "bytes" - "encoding/binary" - "io" - "math/big" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/consensus/progpow" - "github.com/dominant-strategies/go-quai/core" - "github.com/dominant-strategies/go-quai/core/rawdb" - "github.com/dominant-strategies/go-quai/core/types" - "github.com/dominant-strategies/go-quai/core/vm" - "github.com/dominant-strategies/go-quai/crypto" - "github.com/dominant-strategies/go-quai/params" - "github.com/dominant-strategies/go-quai/rlp" - "github.com/dominant-strategies/go-quai/trie" -) - -var ( - bankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - bankAddr = crypto.PubkeyToAddress(bankKey.PublicKey) - bankFunds = new(big.Int).Mul(big.NewInt(100), big.NewInt(params.Ether)) - - testChainLen = 256 - testContractCode = common.Hex2Bytes("606060405260cc8060106000396000f360606040526000357c01000000000000000000000000000000000000000000000000000000009004806360cd2685146041578063c16431b914606b57603f565b005b6055600480803590602001909190505060a9565b6040518082815260200191505060405180910390f35b60886004808035906020019091908035906020019091905050608a565b005b80600060005083606481101560025790900160005b50819055505b5050565b6000600060005082606481101560025790900160005b5054905060c7565b91905056") - - chain *core.BlockChain - addrHashes []common.Hash - txHashes []common.Hash - - chtTrie *trie.Trie - bloomTrie *trie.Trie - chtKeys [][]byte - bloomKeys [][]byte -) - -func makechain() (bc *core.BlockChain, addrHashes, txHashes []common.Hash) { - db := rawdb.NewMemoryDatabase() - gspec := core.Genesis{ - Config: params.TestChainConfig, - Alloc: core.GenesisAlloc{bankAddr: {Balance: bankFunds}}, - GasLimit: 100000000, - } - genesis := gspec.MustCommit(db) - signer := types.LatestSigner(params.RopstenChainConfig) - blocks, _ := core.GenerateChain(gspec.Config, genesis, progpow.NewFaker(), db, testChainLen, - func(i int, gen *core.BlockGen) { - var ( - tx *types.Transaction - addr common.Address - ) - nonce := uint64(i) - if i%4 == 0 { - tx, _ = types.SignTx(types.NewContractCreation(nonce, big.NewInt(0), 200000, big.NewInt(0), testContractCode), signer, bankKey) - addr = crypto.CreateAddress(bankAddr, nonce) - } else { - addr = common.BigToAddress(big.NewInt(int64(i))) - tx, _ = types.SignTx(types.NewTransaction(nonce, addr, big.NewInt(10000), params.TxGas, big.NewInt(params.GWei), nil), signer, bankKey) - } - gen.AddTx(tx) - addrHashes = append(addrHashes, crypto.Keccak256Hash(addr[:])) - txHashes = append(txHashes, tx.Hash()) - }) - bc, _ = core.NewBlockChain(db, nil, gspec.Config, progpow.NewFaker(), vm.Config{}, nil, nil) - if _, err := bc.InsertChain(blocks); err != nil { - panic(err) - } - return -} - -func makeTries() (chtTrie *trie.Trie, bloomTrie *trie.Trie, chtKeys, bloomKeys [][]byte) { - chtTrie, _ = trie.New(common.Hash{}, trie.NewDatabase(rawdb.NewMemoryDatabase())) - bloomTrie, _ = trie.New(common.Hash{}, trie.NewDatabase(rawdb.NewMemoryDatabase())) - for i := 0; i < testChainLen; i++ { - // The element in CHT is -> - key := make([]byte, 8) - binary.BigEndian.PutUint64(key, uint64(i+1)) - chtTrie.Update(key, []byte{0x1, 0xf}) - chtKeys = append(chtKeys, key) - - // The element in Bloom trie is <2 byte bit index> + -> bloom - key2 := make([]byte, 10) - binary.BigEndian.PutUint64(key2[2:], uint64(i+1)) - bloomTrie.Update(key2, []byte{0x2, 0xe}) - bloomKeys = append(bloomKeys, key2) - } - return -} - -func init() { - chain, addrHashes, txHashes = makechain() - chtTrie, bloomTrie, chtKeys, bloomKeys = makeTries() -} - -type fuzzer struct { - chain *core.BlockChain - pool *core.TxPool - - chainLen int - addr, txs []common.Hash - nonce uint64 - - chtKeys [][]byte - bloomKeys [][]byte - chtTrie *trie.Trie - bloomTrie *trie.Trie - - input io.Reader - exhausted bool -} - -func newFuzzer(input []byte) *fuzzer { - return &fuzzer{ - chain: chain, - chainLen: testChainLen, - addr: addrHashes, - txs: txHashes, - chtTrie: chtTrie, - bloomTrie: bloomTrie, - chtKeys: chtKeys, - bloomKeys: bloomKeys, - nonce: uint64(len(txHashes)), - pool: core.NewTxPool(core.DefaultTxPoolConfig, params.TestChainConfig, chain), - input: bytes.NewReader(input), - } -} - -func (f *fuzzer) read(size int) []byte { - out := make([]byte, size) - if _, err := f.input.Read(out); err != nil { - f.exhausted = true - } - return out -} - -func (f *fuzzer) randomByte() byte { - d := f.read(1) - return d[0] -} - -func (f *fuzzer) randomBool() bool { - d := f.read(1) - return d[0]&1 == 1 -} - -func (f *fuzzer) randomInt(max int) int { - if max == 0 { - return 0 - } - if max <= 256 { - return int(f.randomByte()) % max - } - var a uint16 - if err := binary.Read(f.input, binary.LittleEndian, &a); err != nil { - f.exhausted = true - } - return int(a % uint16(max)) -} - -func (f *fuzzer) randomX(max int) uint64 { - var a uint16 - if err := binary.Read(f.input, binary.LittleEndian, &a); err != nil { - f.exhausted = true - } - if a < 0x8000 { - return uint64(a%uint16(max+1)) - 1 - } - return (uint64(1)<<(a%64+1) - 1) & (uint64(a) * 343897772345826595) -} - -func (f *fuzzer) randomBlockHash() common.Hash { - h := f.chain.GetCanonicalHash(uint64(f.randomInt(3 * f.chainLen))) - if h != (common.Hash{}) { - return h - } - return common.BytesToHash(f.read(common.HashLength)) -} - -func (f *fuzzer) randomAddrHash() []byte { - i := f.randomInt(3 * len(f.addr)) - if i < len(f.addr) { - return f.addr[i].Bytes() - } - return f.read(common.HashLength) -} - -func (f *fuzzer) randomCHTTrieKey() []byte { - i := f.randomInt(3 * len(f.chtKeys)) - if i < len(f.chtKeys) { - return f.chtKeys[i] - } - return f.read(8) -} - -func (f *fuzzer) randomBloomTrieKey() []byte { - i := f.randomInt(3 * len(f.bloomKeys)) - if i < len(f.bloomKeys) { - return f.bloomKeys[i] - } - return f.read(10) -} - -func (f *fuzzer) randomTxHash() common.Hash { - i := f.randomInt(3 * len(f.txs)) - if i < len(f.txs) { - return f.txs[i] - } - return common.BytesToHash(f.read(common.HashLength)) -} - -func (f *fuzzer) BlockChain() *core.BlockChain { - return f.chain -} - -func (f *fuzzer) TxPool() *core.TxPool { - return f.pool -} - -func (f *fuzzer) ArchiveMode() bool { - return false -} - -func (f *fuzzer) AddTxsSync() bool { - return false -} - -func (f *fuzzer) GetHelperTrie(typ uint, index uint64) *trie.Trie { - if typ == 0 { - return f.chtTrie - } else if typ == 1 { - return f.bloomTrie - } - return nil -} - -type dummyMsg struct { - data []byte -} - -func (d dummyMsg) Decode(val interface{}) error { - return rlp.DecodeBytes(d.data, val) -} - -func (f *fuzzer) doFuzz(msgCode uint64, packet interface{}) { - enc, err := rlp.EncodeToBytes(packet) - if err != nil { - panic(err) - } - version := f.randomInt(3) + 2 // [LES2, LES3, LES4] - peer, closeFn := l.NewFuzzerPeer(version) - defer closeFn() - fn, _, _, err := l.Les3[msgCode].Handle(dummyMsg{enc}) - if err != nil { - panic(err) - } - fn(f, peer, func() bool { return true }) -} - -func Fuzz(input []byte) int { - // We expect some large inputs - if len(input) < 100 { - return -1 - } - f := newFuzzer(input) - if f.exhausted { - return -1 - } - for !f.exhausted { - switch f.randomInt(8) { - case 0: - req := &l.GetBlockHeadersPacket{ - Query: l.GetBlockHeadersData{ - Amount: f.randomX(l.MaxHeaderFetch + 1), - Skip: f.randomX(10), - Reverse: f.randomBool(), - }, - } - if f.randomBool() { - req.Query.Origin.Hash = f.randomBlockHash() - } else { - req.Query.Origin.Number() = uint64(f.randomInt(f.chainLen * 2)) - } - f.doFuzz(l.GetBlockHeadersMsg, req) - - case 1: - req := &l.GetBlockBodiesPacket{Hashes: make([]common.Hash, f.randomInt(l.MaxBodyFetch+1))} - for i := range req.Hashes { - req.Hashes[i] = f.randomBlockHash() - } - f.doFuzz(l.GetBlockBodiesMsg, req) - - case 2: - req := &l.GetCodePacket{Reqs: make([]l.CodeReq, f.randomInt(l.MaxCodeFetch+1))} - for i := range req.Reqs { - req.Reqs[i] = l.CodeReq{ - BHash: f.randomBlockHash(), - AccKey: f.randomAddrHash(), - } - } - f.doFuzz(l.GetCodeMsg, req) - - case 3: - req := &l.GetReceiptsPacket{Hashes: make([]common.Hash, f.randomInt(l.MaxReceiptFetch+1))} - for i := range req.Hashes { - req.Hashes[i] = f.randomBlockHash() - } - f.doFuzz(l.GetReceiptsMsg, req) - - case 4: - req := &l.GetProofsPacket{Reqs: make([]l.ProofReq, f.randomInt(l.MaxProofsFetch+1))} - for i := range req.Reqs { - if f.randomBool() { - req.Reqs[i] = l.ProofReq{ - BHash: f.randomBlockHash(), - AccKey: f.randomAddrHash(), - Key: f.randomAddrHash(), - FromLevel: uint(f.randomX(3)), - } - } else { - req.Reqs[i] = l.ProofReq{ - BHash: f.randomBlockHash(), - Key: f.randomAddrHash(), - FromLevel: uint(f.randomX(3)), - } - } - } - f.doFuzz(l.GetProofsV2Msg, req) - - case 5: - req := &l.GetHelperTrieProofsPacket{Reqs: make([]l.HelperTrieReq, f.randomInt(l.MaxHelperTrieProofsFetch+1))} - for i := range req.Reqs { - switch f.randomInt(3) { - case 0: - // Canonical hash trie - req.Reqs[i] = l.HelperTrieReq{ - Type: 0, - TrieIdx: f.randomX(3), - Key: f.randomCHTTrieKey(), - FromLevel: uint(f.randomX(3)), - AuxReq: uint(2), - } - case 1: - // Bloom trie - req.Reqs[i] = l.HelperTrieReq{ - Type: 1, - TrieIdx: f.randomX(3), - Key: f.randomBloomTrieKey(), - FromLevel: uint(f.randomX(3)), - AuxReq: 0, - } - default: - // Random trie - req.Reqs[i] = l.HelperTrieReq{ - Type: 2, - TrieIdx: f.randomX(3), - Key: f.randomCHTTrieKey(), - FromLevel: uint(f.randomX(3)), - AuxReq: 0, - } - } - } - f.doFuzz(l.GetHelperTrieProofsMsg, req) - - case 6: - req := &l.SendTxPacket{Txs: make([]*types.Transaction, f.randomInt(l.MaxTxSend+1))} - signer := types.LatestSigner(params.RopstenChainConfig) - for i := range req.Txs { - var nonce uint64 - if f.randomBool() { - nonce = uint64(f.randomByte()) - } else { - nonce = f.nonce - f.nonce += 1 - } - req.Txs[i], _ = types.SignTx(types.NewTransaction(nonce, common.Address{}, big.NewInt(10000), params.TxGas, big.NewInt(1000000000*int64(f.randomByte())), nil), signer, bankKey) - } - f.doFuzz(l.SendTxV2Msg, req) - - case 7: - req := &l.GetTxStatusPacket{Hashes: make([]common.Hash, f.randomInt(l.MaxTxStatus+1))} - for i := range req.Hashes { - req.Hashes[i] = f.randomTxHash() - } - f.doFuzz(l.GetTxStatusMsg, req) - } - } - return 0 -} diff --git a/tests/fuzzers/rangeproof/corpus/1c14030f26872e57bf1481084f151d71eed8161c-1 b/tests/fuzzers/rangeproof/corpus/1c14030f26872e57bf1481084f151d71eed8161c-1 deleted file mode 100644 index 31c08bafaf..0000000000 Binary files a/tests/fuzzers/rangeproof/corpus/1c14030f26872e57bf1481084f151d71eed8161c-1 and /dev/null differ diff --git a/tests/fuzzers/rangeproof/corpus/27e54254422543060a13ea8a4bc913d768e4adb6-2 b/tests/fuzzers/rangeproof/corpus/27e54254422543060a13ea8a4bc913d768e4adb6-2 deleted file mode 100644 index 7bce13ef80..0000000000 Binary files a/tests/fuzzers/rangeproof/corpus/27e54254422543060a13ea8a4bc913d768e4adb6-2 and /dev/null differ diff --git a/tests/fuzzers/rangeproof/corpus/6bfc2cbe2d7a43361e240118439785445a0fdfb7-5 b/tests/fuzzers/rangeproof/corpus/6bfc2cbe2d7a43361e240118439785445a0fdfb7-5 deleted file mode 100644 index 613e76a020..0000000000 Binary files a/tests/fuzzers/rangeproof/corpus/6bfc2cbe2d7a43361e240118439785445a0fdfb7-5 and /dev/null differ diff --git a/tests/fuzzers/rangeproof/corpus/a67e63bc0c0004bd009944a6061297cb7d4ac238-1 b/tests/fuzzers/rangeproof/corpus/a67e63bc0c0004bd009944a6061297cb7d4ac238-1 deleted file mode 100644 index 805ad8df77..0000000000 Binary files a/tests/fuzzers/rangeproof/corpus/a67e63bc0c0004bd009944a6061297cb7d4ac238-1 and /dev/null differ diff --git a/tests/fuzzers/rangeproof/corpus/ae892bbae0a843950bc8316496e595b1a194c009-4 b/tests/fuzzers/rangeproof/corpus/ae892bbae0a843950bc8316496e595b1a194c009-4 deleted file mode 100644 index 605acf81c1..0000000000 Binary files a/tests/fuzzers/rangeproof/corpus/ae892bbae0a843950bc8316496e595b1a194c009-4 and /dev/null differ diff --git a/tests/fuzzers/rangeproof/corpus/ee05d0d813f6261b3dba16506f9ea03d9c5e993d-2 b/tests/fuzzers/rangeproof/corpus/ee05d0d813f6261b3dba16506f9ea03d9c5e993d-2 deleted file mode 100644 index 8f32dd775a..0000000000 Binary files a/tests/fuzzers/rangeproof/corpus/ee05d0d813f6261b3dba16506f9ea03d9c5e993d-2 and /dev/null differ diff --git a/tests/fuzzers/rangeproof/corpus/f50a6d57a46d30184aa294af5b252ab9701af7c9-2 b/tests/fuzzers/rangeproof/corpus/f50a6d57a46d30184aa294af5b252ab9701af7c9-2 deleted file mode 100644 index af96210f20..0000000000 Binary files a/tests/fuzzers/rangeproof/corpus/f50a6d57a46d30184aa294af5b252ab9701af7c9-2 and /dev/null differ diff --git a/tests/fuzzers/rangeproof/corpus/random.dat b/tests/fuzzers/rangeproof/corpus/random.dat deleted file mode 100644 index 2c998ad812..0000000000 Binary files a/tests/fuzzers/rangeproof/corpus/random.dat and /dev/null differ diff --git a/tests/fuzzers/rangeproof/debug/main.go b/tests/fuzzers/rangeproof/debug/main.go deleted file mode 100644 index 5e936e8169..0000000000 --- a/tests/fuzzers/rangeproof/debug/main.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2020 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package main - -import ( - "fmt" - "io/ioutil" - "os" - - "github.com/dominant-strategies/go-quai/tests/fuzzers/rangeproof" -) - -func main() { - if len(os.Args) != 2 { - fmt.Fprintf(os.Stderr, "Usage: debug \n") - fmt.Fprintf(os.Stderr, "Example\n") - fmt.Fprintf(os.Stderr, " $ debug ../crashers/4bbef6857c733a87ecf6fd8b9e7238f65eb9862a\n") - os.Exit(1) - } - crasher := os.Args[1] - data, err := ioutil.ReadFile(crasher) - if err != nil { - fmt.Fprintf(os.Stderr, "error loading crasher %v: %v", crasher, err) - os.Exit(1) - } - rangeproof.Fuzz(data) -} diff --git a/tests/fuzzers/rangeproof/rangeproof-fuzzer.go b/tests/fuzzers/rangeproof/rangeproof-fuzzer.go deleted file mode 100644 index 2e6a6ebf89..0000000000 --- a/tests/fuzzers/rangeproof/rangeproof-fuzzer.go +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2020 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package rangeproof - -import ( - "bytes" - "encoding/binary" - "fmt" - "io" - "sort" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/ethdb/memorydb" - "github.com/dominant-strategies/go-quai/trie" -) - -type kv struct { - k, v []byte - t bool -} - -type entrySlice []*kv - -func (p entrySlice) Len() int { return len(p) } -func (p entrySlice) Less(i, j int) bool { return bytes.Compare(p[i].k, p[j].k) < 0 } -func (p entrySlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } - -type fuzzer struct { - input io.Reader - exhausted bool -} - -func (f *fuzzer) randBytes(n int) []byte { - r := make([]byte, n) - if _, err := f.input.Read(r); err != nil { - f.exhausted = true - } - return r -} - -func (f *fuzzer) readInt() uint64 { - var x uint64 - if err := binary.Read(f.input, binary.LittleEndian, &x); err != nil { - f.exhausted = true - } - return x -} - -func (f *fuzzer) randomTrie(n int) (*trie.Trie, map[string]*kv) { - - trie := new(trie.Trie) - vals := make(map[string]*kv) - size := f.readInt() - // Fill it with some fluff - for i := byte(0); i < byte(size); i++ { - value := &kv{common.LeftPadBytes([]byte{i}, 32), []byte{i}, false} - value2 := &kv{common.LeftPadBytes([]byte{i + 10}, 32), []byte{i}, false} - trie.Update(value.k, value.v) - trie.Update(value2.k, value2.v) - vals[string(value.k)] = value - vals[string(value2.k)] = value2 - } - if f.exhausted { - return nil, nil - } - // And now fill with some random - for i := 0; i < n; i++ { - k := f.randBytes(32) - v := f.randBytes(20) - value := &kv{k, v, false} - trie.Update(k, v) - vals[string(k)] = value - if f.exhausted { - return nil, nil - } - } - return trie, vals -} - -func (f *fuzzer) fuzz() int { - maxSize := 200 - tr, vals := f.randomTrie(1 + int(f.readInt())%maxSize) - if f.exhausted { - return 0 // input too short - } - var entries entrySlice - for _, kv := range vals { - entries = append(entries, kv) - } - if len(entries) <= 1 { - return 0 - } - sort.Sort(entries) - - var ok = 0 - for { - start := int(f.readInt() % uint64(len(entries))) - end := 1 + int(f.readInt()%uint64(len(entries)-1)) - testcase := int(f.readInt() % uint64(6)) - index := int(f.readInt() & 0xFFFFFFFF) - index2 := int(f.readInt() & 0xFFFFFFFF) - if f.exhausted { - break - } - proof := memorydb.New() - if err := tr.Prove(entries[start].k, 0, proof); err != nil { - panic(fmt.Sprintf("Failed to prove the first node %v", err)) - } - if err := tr.Prove(entries[end-1].k, 0, proof); err != nil { - panic(fmt.Sprintf("Failed to prove the last node %v", err)) - } - var keys [][]byte - var vals [][]byte - for i := start; i < end; i++ { - keys = append(keys, entries[i].k) - vals = append(vals, entries[i].v) - } - if len(keys) == 0 { - return 0 - } - var first, last = keys[0], keys[len(keys)-1] - testcase %= 6 - switch testcase { - case 0: - // Modified key - keys[index%len(keys)] = f.randBytes(32) // In theory it can't be same - case 1: - // Modified val - vals[index%len(vals)] = f.randBytes(20) // In theory it can't be same - case 2: - // Gapped entry slice - index = index % len(keys) - keys = append(keys[:index], keys[index+1:]...) - vals = append(vals[:index], vals[index+1:]...) - case 3: - // Out of order - index1 := index % len(keys) - index2 := index2 % len(keys) - keys[index1], keys[index2] = keys[index2], keys[index1] - vals[index1], vals[index2] = vals[index2], vals[index1] - case 4: - // Set random key to nil, do nothing - keys[index%len(keys)] = nil - case 5: - // Set random value to nil, deletion - vals[index%len(vals)] = nil - - // Other cases: - // Modify something in the proof db - // add stuff to proof db - // drop stuff from proof db - - } - if f.exhausted { - break - } - ok = 1 - //nodes, subtrie - hasMore, err := trie.VerifyRangeProof(tr.Hash(), first, last, keys, vals, proof) - if err != nil { - if hasMore { - panic("err != nil && hasMore == true") - } - } - } - return ok -} - -// The function must return -// 1 if the fuzzer should increase priority of the -// given input during subsequent fuzzing (for example, the input is lexically -// correct and was parsed successfully); -// -1 if the input must not be added to corpus even if gives new coverage; and -// 0 otherwise; other values are reserved for future use. -func Fuzz(input []byte) int { - if len(input) < 100 { - return 0 - } - r := bytes.NewReader(input) - f := fuzzer{ - input: r, - exhausted: false, - } - return f.fuzz() -} diff --git a/tests/fuzzers/rlp/corpus/block_with_uncle.rlp b/tests/fuzzers/rlp/corpus/block_with_uncle.rlp deleted file mode 100644 index 1b49fe6a09..0000000000 Binary files a/tests/fuzzers/rlp/corpus/block_with_uncle.rlp and /dev/null differ diff --git a/tests/fuzzers/rlp/corpus/r.bin b/tests/fuzzers/rlp/corpus/r.bin deleted file mode 100644 index cb98a76a8a..0000000000 --- a/tests/fuzzers/rlp/corpus/r.bin +++ /dev/null @@ -1 +0,0 @@ -ˀ \ No newline at end of file diff --git a/tests/fuzzers/rlp/corpus/transaction.rlp b/tests/fuzzers/rlp/corpus/transaction.rlp deleted file mode 100644 index 80eea1aec6..0000000000 --- a/tests/fuzzers/rlp/corpus/transaction.rlp +++ /dev/null @@ -1,2 +0,0 @@ -N -aP?-'{ЋDYfj\E~읕F?1(ij6@v Lڑ \ No newline at end of file diff --git a/tests/fuzzers/rlp/rlp_fuzzer.go b/tests/fuzzers/rlp/rlp_fuzzer.go deleted file mode 100644 index 2542779f3e..0000000000 --- a/tests/fuzzers/rlp/rlp_fuzzer.go +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2019 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package rlp - -import ( - "bytes" - "fmt" - - "github.com/dominant-strategies/go-quai/core/types" - "github.com/dominant-strategies/go-quai/rlp" -) - -func decodeEncode(input []byte, val interface{}, i int) { - if err := rlp.DecodeBytes(input, val); err == nil { - output, err := rlp.EncodeToBytes(val) - if err != nil { - panic(err) - } - if !bytes.Equal(input, output) { - panic(fmt.Sprintf("case %d: encode-decode is not equal, \ninput : %x\noutput: %x", i, input, output)) - } - } -} - -func Fuzz(input []byte) int { - if len(input) == 0 { - return 0 - } - - var i int - { - rlp.Split(input) - } - { - if elems, _, err := rlp.SplitList(input); err == nil { - rlp.CountValues(elems) - } - } - - { - rlp.NewStream(bytes.NewReader(input), 0).Decode(new(interface{})) - } - - { - decodeEncode(input, new(interface{}), i) - i++ - } - { - var v struct { - Int uint - String string - Bytes []byte - } - decodeEncode(input, &v, i) - i++ - } - - { - type Types struct { - Bool bool - Raw rlp.RawValue - Slice []*Types - Iface []interface{} - } - var v Types - decodeEncode(input, &v, i) - i++ - } - { - type AllTypes struct { - Int uint - String string - Bytes []byte - Bool bool - Raw rlp.RawValue - Slice []*AllTypes - Array [3]*AllTypes - Iface []interface{} - } - var v AllTypes - decodeEncode(input, &v, i) - i++ - } - { - decodeEncode(input, [10]byte{}, i) - i++ - } - { - var v struct { - Byte [10]byte - Rool [10]bool - } - decodeEncode(input, &v, i) - i++ - } - { - var h types.Header - decodeEncode(input, &h, i) - i++ - var b types.Block - decodeEncode(input, &b, i) - i++ - var t types.Transaction - decodeEncode(input, &t, i) - i++ - var txs types.Transactions - decodeEncode(input, &txs, i) - i++ - var rs types.Receipts - decodeEncode(input, &rs, i) - } - return 1 -} diff --git a/tests/fuzzers/runtime/runtime_fuzz.go b/tests/fuzzers/runtime/runtime_fuzz.go deleted file mode 100644 index e52a509be7..0000000000 --- a/tests/fuzzers/runtime/runtime_fuzz.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package runtime - -import ( - "github.com/dominant-strategies/go-quai/core/vm/runtime" -) - -// Fuzz is the basic entry point for the go-fuzz tool -// -// This returns 1 for valid parsable/runable code, 0 -// for invalid opcode. -func Fuzz(input []byte) int { - _, _, err := runtime.Execute(input, input, &runtime.Config{ - GasLimit: 12000000, - }) - // invalid opcode - if err != nil && len(err.Error()) > 6 && err.Error()[:7] == "invalid" { - return 0 - } - return 1 -} diff --git a/tests/fuzzers/secp256k1/secp_fuzzer.go b/tests/fuzzers/secp256k1/secp_fuzzer.go deleted file mode 100644 index 338e3d46c8..0000000000 --- a/tests/fuzzers/secp256k1/secp_fuzzer.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2021 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -// build +gofuzz - -package secp256k1 - -import ( - "fmt" - - "github.com/btcsuite/btcd/btcec" - fuzz "github.com/google/gofuzz" - "github.com/ledgerwatch/secp256k1" -) - -func Fuzz(input []byte) int { - var ( - fuzzer = fuzz.NewFromGoFuzz(input) - curveA = secp256k1.S256() - curveB = btcec.S256() - dataP1 []byte - dataP2 []byte - ) - // first point - fuzzer.Fuzz(&dataP1) - x1, y1 := curveB.ScalarBaseMult(dataP1) - // second point - fuzzer.Fuzz(&dataP2) - x2, y2 := curveB.ScalarBaseMult(dataP2) - resAX, resAY := curveA.Add(x1, y1, x2, y2) - resBX, resBY := curveB.Add(x1, y1, x2, y2) - if resAX.Cmp(resBX) != 0 || resAY.Cmp(resBY) != 0 { - fmt.Printf("%s %s %s %s\n", x1, y1, x2, y2) - panic(fmt.Sprintf("Addition failed: quai: %s %s btcd: %s %s", resAX, resAY, resBX, resBY)) - } - return 0 -} diff --git a/tests/fuzzers/secp256k1/secp_test.go b/tests/fuzzers/secp256k1/secp_test.go deleted file mode 100644 index 76bae87086..0000000000 --- a/tests/fuzzers/secp256k1/secp_test.go +++ /dev/null @@ -1,8 +0,0 @@ -package secp256k1 - -import "testing" - -func TestFuzzer(t *testing.T) { - test := "00000000N0000000/R00000000000000000U0000S0000000mkhP000000000000000U" - Fuzz([]byte(test)) -} diff --git a/tests/fuzzers/stacktrie/debug/main.go b/tests/fuzzers/stacktrie/debug/main.go deleted file mode 100644 index f75abb0b73..0000000000 --- a/tests/fuzzers/stacktrie/debug/main.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ( - "fmt" - "io/ioutil" - "os" - - "github.com/dominant-strategies/go-quai/tests/fuzzers/stacktrie" -) - -func main() { - if len(os.Args) != 2 { - fmt.Fprintf(os.Stderr, "Usage: debug ") - os.Exit(1) - } - crasher := os.Args[1] - data, err := ioutil.ReadFile(crasher) - if err != nil { - fmt.Fprintf(os.Stderr, "error loading crasher %v: %v", crasher, err) - os.Exit(1) - } - stacktrie.Debug(data) -} diff --git a/tests/fuzzers/stacktrie/trie_fuzzer.go b/tests/fuzzers/stacktrie/trie_fuzzer.go deleted file mode 100644 index 940590a440..0000000000 --- a/tests/fuzzers/stacktrie/trie_fuzzer.go +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2020 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package stacktrie - -import ( - "bytes" - "encoding/binary" - "errors" - "fmt" - "hash" - "io" - "sort" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/ethdb" - "github.com/dominant-strategies/go-quai/trie" - "golang.org/x/crypto/sha3" -) - -type fuzzer struct { - input io.Reader - exhausted bool - debugging bool -} - -func (f *fuzzer) read(size int) []byte { - out := make([]byte, size) - if _, err := f.input.Read(out); err != nil { - f.exhausted = true - } - return out -} - -func (f *fuzzer) readSlice(min, max int) []byte { - var a uint16 - binary.Read(f.input, binary.LittleEndian, &a) - size := min + int(a)%(max-min) - out := make([]byte, size) - if _, err := f.input.Read(out); err != nil { - f.exhausted = true - } - return out -} - -// spongeDb is a dummy db backend which accumulates writes in a sponge -type spongeDb struct { - sponge hash.Hash - debug bool -} - -func (s *spongeDb) Has(key []byte) (bool, error) { panic("implement me") } -func (s *spongeDb) Get(key []byte) ([]byte, error) { return nil, errors.New("no such elem") } -func (s *spongeDb) Delete(key []byte) error { panic("implement me") } -func (s *spongeDb) NewBatch() ethdb.Batch { return &spongeBatch{s} } -func (s *spongeDb) Stat(property string) (string, error) { panic("implement me") } -func (s *spongeDb) Compact(start []byte, limit []byte) error { panic("implement me") } -func (s *spongeDb) Close() error { return nil } - -func (s *spongeDb) Put(key []byte, value []byte) error { - if s.debug { - fmt.Printf("db.Put %x : %x\n", key, value) - } - s.sponge.Write(key) - s.sponge.Write(value) - return nil -} -func (s *spongeDb) NewIterator(prefix []byte, start []byte) ethdb.Iterator { panic("implement me") } - -// spongeBatch is a dummy batch which immediately writes to the underlying spongedb -type spongeBatch struct { - db *spongeDb -} - -func (b *spongeBatch) Put(key, value []byte) error { - b.db.Put(key, value) - return nil -} -func (b *spongeBatch) Delete(key []byte) error { panic("implement me") } -func (b *spongeBatch) ValueSize() int { return 100 } -func (b *spongeBatch) Write() error { return nil } -func (b *spongeBatch) Reset() {} -func (b *spongeBatch) Replay(w ethdb.KeyValueWriter) error { return nil } - -type kv struct { - k, v []byte -} -type kvs []kv - -func (k kvs) Len() int { - return len(k) -} - -func (k kvs) Less(i, j int) bool { - return bytes.Compare(k[i].k, k[j].k) < 0 -} - -func (k kvs) Swap(i, j int) { - k[j], k[i] = k[i], k[j] -} - -// The function must return -// 1 if the fuzzer should increase priority of the -// given input during subsequent fuzzing (for example, the input is lexically -// correct and was parsed successfully); -// -1 if the input must not be added to corpus even if gives new coverage; and -// 0 otherwise -// other values are reserved for future use. -func Fuzz(data []byte) int { - f := fuzzer{ - input: bytes.NewReader(data), - exhausted: false, - } - return f.fuzz() -} - -func Debug(data []byte) int { - f := fuzzer{ - input: bytes.NewReader(data), - exhausted: false, - debugging: true, - } - return f.fuzz() -} - -func (f *fuzzer) fuzz() int { - - // This spongeDb is used to check the sequence of disk-db-writes - var ( - spongeA = &spongeDb{sponge: sha3.NewLegacyKeccak256()} - dbA = trie.NewDatabase(spongeA) - trieA, _ = trie.New(common.Hash{}, dbA) - spongeB = &spongeDb{sponge: sha3.NewLegacyKeccak256()} - trieB = trie.NewStackTrie(spongeB) - vals kvs - useful bool - maxElements = 10000 - // operate on unique keys only - keys = make(map[string]struct{}) - ) - // Fill the trie with elements - for i := 0; !f.exhausted && i < maxElements; i++ { - k := f.read(32) - v := f.readSlice(1, 500) - if f.exhausted { - // If it was exhausted while reading, the value may be all zeroes, - // thus 'deletion' which is not supported on stacktrie - break - } - if _, present := keys[string(k)]; present { - // This key is a duplicate, ignore it - continue - } - keys[string(k)] = struct{}{} - vals = append(vals, kv{k: k, v: v}) - trieA.Update(k, v) - useful = true - } - if !useful { - return 0 - } - // Flush trie -> database - rootA, err := trieA.Commit(nil) - if err != nil { - panic(err) - } - // Flush memdb -> disk (sponge) - dbA.Commit(rootA, false, nil) - - // Stacktrie requires sorted insertion - sort.Sort(vals) - for _, kv := range vals { - if f.debugging { - fmt.Printf("{\"0x%x\" , \"0x%x\"} // stacktrie.Update\n", kv.k, kv.v) - } - trieB.Update(kv.k, kv.v) - } - rootB := trieB.Hash() - if _, err := trieB.Commit(); err != nil { - panic(err) - } - if rootA != rootB { - panic(fmt.Sprintf("roots differ: (trie) %x != %x (stacktrie)", rootA, rootB)) - } - sumA := spongeA.sponge.Sum(nil) - sumB := spongeB.sponge.Sum(nil) - if !bytes.Equal(sumA, sumB) { - panic(fmt.Sprintf("sequence differ: (trie) %x != %x (stacktrie)", sumA, sumB)) - } - return 1 -} diff --git a/tests/fuzzers/trie/corpus/data b/tests/fuzzers/trie/corpus/data deleted file mode 100644 index c4a4839cb8..0000000000 --- a/tests/fuzzers/trie/corpus/data +++ /dev/null @@ -1 +0,0 @@ -asdlfkjasf23oiejfasdfadkfqlkjfasdlkfjalwk4jfalsdkfjawlefkjsadlfkjasldkfjwalefkjasdlfkjM \ No newline at end of file diff --git a/tests/fuzzers/trie/trie-fuzzer.go b/tests/fuzzers/trie/trie-fuzzer.go deleted file mode 100644 index 9d343a882c..0000000000 --- a/tests/fuzzers/trie/trie-fuzzer.go +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright 2019 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package trie - -import ( - "bytes" - "encoding/binary" - "fmt" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/ethdb/memorydb" - "github.com/dominant-strategies/go-quai/trie" -) - -// randTest performs random trie operations. -// Instances of this test are created by Generate. -type randTest []randTestStep - -type randTestStep struct { - op int - key []byte // for opUpdate, opDelete, opGet - value []byte // for opUpdate - err error // for debugging -} - -type proofDb struct{} - -func (proofDb) Put(key []byte, value []byte) error { - return nil -} - -func (proofDb) Delete(key []byte) error { - return nil -} - -const ( - opUpdate = iota - opDelete - opGet - opCommit - opHash - opReset - opItercheckhash - opProve - opMax // boundary value, not an actual op -) - -type dataSource struct { - input []byte - reader *bytes.Reader -} - -func newDataSource(input []byte) *dataSource { - return &dataSource{ - input, bytes.NewReader(input), - } -} -func (ds *dataSource) ReadByte() byte { - if b, err := ds.reader.ReadByte(); err != nil { - return 0 - } else { - return b - } -} -func (ds *dataSource) Read(buf []byte) (int, error) { - return ds.reader.Read(buf) -} -func (ds *dataSource) Ended() bool { - return ds.reader.Len() == 0 -} - -func Generate(input []byte) randTest { - - var allKeys [][]byte - r := newDataSource(input) - genKey := func() []byte { - - if len(allKeys) < 2 || r.ReadByte() < 0x0f { - // new key - key := make([]byte, r.ReadByte()%50) - r.Read(key) - allKeys = append(allKeys, key) - return key - } - // use existing key - return allKeys[int(r.ReadByte())%len(allKeys)] - } - - var steps randTest - - for i := 0; !r.Ended(); i++ { - - step := randTestStep{op: int(r.ReadByte()) % opMax} - switch step.op { - case opUpdate: - step.key = genKey() - step.value = make([]byte, 8) - binary.BigEndian.PutUint64(step.value, uint64(i)) - case opGet, opDelete, opProve: - step.key = genKey() - } - steps = append(steps, step) - if len(steps) > 500 { - break - } - } - - return steps -} - -// The function must return -// 1 if the fuzzer should increase priority of the -// given input during subsequent fuzzing (for example, the input is lexically -// correct and was parsed successfully); -// -1 if the input must not be added to corpus even if gives new coverage; and -// 0 otherwise -// other values are reserved for future use. -func Fuzz(input []byte) int { - program := Generate(input) - if len(program) == 0 { - return 0 - } - if err := runRandTest(program); err != nil { - panic(err) - } - return 1 -} - -func runRandTest(rt randTest) error { - - triedb := trie.NewDatabase(memorydb.New()) - - tr, _ := trie.New(common.Hash{}, triedb) - values := make(map[string]string) // tracks content of the trie - - for i, step := range rt { - switch step.op { - case opUpdate: - tr.Update(step.key, step.value) - values[string(step.key)] = string(step.value) - case opDelete: - tr.Delete(step.key) - delete(values, string(step.key)) - case opGet: - v := tr.Get(step.key) - want := values[string(step.key)] - if string(v) != want { - rt[i].err = fmt.Errorf("mismatch for key 0x%x, got 0x%x want 0x%x", step.key, v, want) - } - case opCommit: - _, rt[i].err = tr.Commit(nil) - case opHash: - tr.Hash() - case opReset: - hash, err := tr.Commit(nil) - if err != nil { - return err - } - newtr, err := trie.New(hash, triedb) - if err != nil { - return err - } - tr = newtr - case opItercheckhash: - checktr, _ := trie.New(common.Hash{}, triedb) - it := trie.NewIterator(tr.NodeIterator(nil)) - for it.Next() { - checktr.Update(it.Key, it.Value) - } - if tr.Hash() != checktr.Hash() { - return fmt.Errorf("hash mismatch in opItercheckhash") - } - case opProve: - rt[i].err = tr.Prove(step.key, 0, proofDb{}) - } - // Abort the test on error. - if rt[i].err != nil { - return rt[i].err - } - } - return nil -} diff --git a/tests/fuzzers/txfetcher/corpus/0151ee1d0db4c74d3bcdfa4f7396a4c8538748c9-2 b/tests/fuzzers/txfetcher/corpus/0151ee1d0db4c74d3bcdfa4f7396a4c8538748c9-2 deleted file mode 100644 index 2c75e9c7a7..0000000000 --- a/tests/fuzzers/txfetcher/corpus/0151ee1d0db4c74d3bcdfa4f7396a4c8538748c9-2 +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/020dd7b492a6eb34ff0b7d8ee46189422c37e4a7-6 b/tests/fuzzers/txfetcher/corpus/020dd7b492a6eb34ff0b7d8ee46189422c37e4a7-6 deleted file mode 100644 index 8d3b57789e..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/020dd7b492a6eb34ff0b7d8ee46189422c37e4a7-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/021d1144e359233c496e22c3250609b11b213e9f-4 b/tests/fuzzers/txfetcher/corpus/021d1144e359233c496e22c3250609b11b213e9f-4 deleted file mode 100644 index 73731899d5..0000000000 --- a/tests/fuzzers/txfetcher/corpus/021d1144e359233c496e22c3250609b11b213e9f-4 +++ /dev/null @@ -1,12 +0,0 @@ - TESTING KEY----- -MIICXgIBAAKBgQDuLnQAI3mDgey3VBzWnB2L39JUU4txjeVE6myuDqkM/uGlfjb9 -SjY1bIw4iAJm2gsvvZhIrCHS3l6afab4pZB -l2+XsDlrKBxKKtDrGxlG4LjncdabFn9gvLZad2bSysqz/qTAUStTtqJQIDAQAB -AoGAGRzwwir7XvBOAy5tuV6ef6anZzus1s1Y1Clb6HbnWWF/wbZGOpet -3m4vD6MXc7jpTLryzTQIvVdfQbRc6+MUVeLKZTXtdZrh+k7hx0nTP8Jcb -uqFk541awmMogY/EfbWd6IOkp+4xqjlFBEDytgbIECQQDvH/6nk+hgN4H -qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQcj2PprIMmPcQrooz84SHEg1Ak/7KCxmD/sfgS5TeuNi8DoUBEmiSJwm7FX -ftxuvL7XvjwjN5B30pNEbc6Iuyt7y4MQJBAIt21su43sjXNueLKH8+ph2UfQuU9txblTu14q3N7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xl/DoCzjA0CQQDU -y2pGsuSmgUtWj3NM9xuwYPm+Z/F84K6+ARYiZ6PYj013sovGKUFfYAqVXVlxtIoX -qUn3Xh9ps8ZfjLZO7BAkEAlT4R5Yl6cGhaJQYZHOde3JMhNRcVFMO8dDaFo -f9Oeos0UotgiDktdQHxdNEwLjQlJBz+OtwwA=---E RATTIEY- \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/0d28327b1fb52c1ba02a6eb96675c31633921bb2-2 b/tests/fuzzers/txfetcher/corpus/0d28327b1fb52c1ba02a6eb96675c31633921bb2-2 deleted file mode 100644 index 8cc3039cb8..0000000000 --- a/tests/fuzzers/txfetcher/corpus/0d28327b1fb52c1ba02a6eb96675c31633921bb2-2 +++ /dev/null @@ -1,15 +0,0 @@ -&^oȗ-----BEGIN RSA TESTING KEY----- -MIICXgIBAAKBgQDuLnQAI3mDgey3VBzWnB2L39JUU4txjeVE6myuDqkM/uGlfjb9 -SjY1bIw4iA5sBBZzHi3z0h1YV8QPuxEbi4nW91IJm2gsvvZhIrCHS3l6afab4pZB -l2+XsDulrKBxKKtD1rGxlG4LjncdabFn9gvLZad2bSysqz/qTAUStTvqJQIDAQAB -AoGAGRzwwir7XvBOAy5tM/uV6e+Zf6anZzus1s1Y1ClbjbE6HXbnWWF/wbZGOpet -3Zm4vD6MXc7jpTLryzTQIvVdfQbRc6+MUVeLKwZatTXtdZrhu+Jk7hx0nTPy8Jcb -uJqFk541aEw+mMogY/xEcfbWd6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nk+hgN4H -qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQcj2PprIMmPcQrooz8vp -jy4SHEg1AkEA/v13/5M47K9vCxmb8QeD/asydfsgS5TeuNi8DoUBEmiSJwma7FXY -fFUtxuvL7XvjwjN5B30pNEbc6Iuyt7y4MQJBAIt21su4b3sjXNueLKH85Q+phy2U -fQtuUE9txblTu14q3N7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xlp/DoCzjA0CQQDU -y2ptGsuSmgUtWj3NM9xuwYPm+Z/F84K6+ARYiZ6PYj013sovGKUFfYAqVXVlxtIX -qyUBnu3X9ps8ZfjLZO7BAkEAlT4R5Yl6cGhaJQYZHOde3JEMhNRcVFMO8dJDaFeo -f9Oeos0UUothgiDktdQHxdNEwLjQf7lJJBzV+5OtwswCWA== ------END RSA TESTING KEY-----Q_ \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/0fcd827b57ded58e91f7ba2ac2b7ea4d25ebedca-7 b/tests/fuzzers/txfetcher/corpus/0fcd827b57ded58e91f7ba2ac2b7ea4d25ebedca-7 deleted file mode 100644 index 8ceee16af1..0000000000 --- a/tests/fuzzers/txfetcher/corpus/0fcd827b57ded58e91f7ba2ac2b7ea4d25ebedca-7 +++ /dev/null @@ -1 +0,0 @@ -ap�￿���V�#�&�� \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/109bc9b8fd4fef63493e104c703c79bc4a5e8d34-6 b/tests/fuzzers/txfetcher/corpus/109bc9b8fd4fef63493e104c703c79bc4a5e8d34-6 deleted file mode 100644 index df9b986af1..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/109bc9b8fd4fef63493e104c703c79bc4a5e8d34-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/163785ab002746452619f31e8dfcb4549e6f8b6e-6 b/tests/fuzzers/txfetcher/corpus/163785ab002746452619f31e8dfcb4549e6f8b6e-6 deleted file mode 100644 index 55467373d4..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/163785ab002746452619f31e8dfcb4549e6f8b6e-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/1adfa6b9ddf5766220c8ff7ede2926ca241bb947-3 b/tests/fuzzers/txfetcher/corpus/1adfa6b9ddf5766220c8ff7ede2926ca241bb947-3 deleted file mode 100644 index 4a593aa28d..0000000000 --- a/tests/fuzzers/txfetcher/corpus/1adfa6b9ddf5766220c8ff7ede2926ca241bb947-3 +++ /dev/null @@ -1,11 +0,0 @@ -TAKBgDuLnQA3gey3VBznB39JUtxjeE6myuDkM/uGlfjb -S1w4iA5sBzzh8uxEbi4nW91IJm2gsvvZhICHS3l6ab4pZB -l2DulrKBxKKtD1rGxlG4LncabFn9vLZad2bSysqz/qTAUSTvqJQIDAQAB -AoGAGRzwwir7XvBOAy5tM/uV6e+Zf6anZzus1s1Y1ClbjbE6HXbnWWF/wbZGOpet -3Z4vMXc7jpTLryzTQIvVdfQbRc6+MUVeLKZatTXtdZrhu+Jk7hx0nTPy8Jcb -uJqFk54MogxEcfbWd6IOkp+4xqFLBEDtgbIECnk+hgN4H -qzzxxr397vWrjrIgbJpQvBv8QeeuNi8DoUBEmiSJwa7FXY -FUtxuvL7XvjwjN5B30pEbc6Iuyt7y4MQJBAIt21su4b3sjphy2tuUE9xblTu14qgHZ6+AiZovGKU--FfYAqVXVlxtIX -qyU3X9ps8ZfjLZ45l6cGhaJQYZHOde3JEMhNRcVFMO8dJDaFeo -f9Oeos0UUothgiDktdQHxdNEwLjQf7lJJBzV+5OtwswCWA== ------END RSA T \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/1b9a02e9a48fea1d2fc3fb77946ada278e152079-4 b/tests/fuzzers/txfetcher/corpus/1b9a02e9a48fea1d2fc3fb77946ada278e152079-4 deleted file mode 100644 index 4a56f93d3b..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/1b9a02e9a48fea1d2fc3fb77946ada278e152079-4 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/1e14c7ea1faef92890988061b5abe96db7190f98-7 b/tests/fuzzers/txfetcher/corpus/1e14c7ea1faef92890988061b5abe96db7190f98-7 deleted file mode 100644 index d2442fc5a6..0000000000 --- a/tests/fuzzers/txfetcher/corpus/1e14c7ea1faef92890988061b5abe96db7190f98-7 +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000000000000000000000000000000000000 \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/1e7d05f00e99cbf3ff0ef1cd7ea8dd07ad6dff23-6 b/tests/fuzzers/txfetcher/corpus/1e7d05f00e99cbf3ff0ef1cd7ea8dd07ad6dff23-6 deleted file mode 100644 index 1c342ff53a..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/1e7d05f00e99cbf3ff0ef1cd7ea8dd07ad6dff23-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/1ec95e347fd522e6385b5091aa81aa2485be4891-4 b/tests/fuzzers/txfetcher/corpus/1ec95e347fd522e6385b5091aa81aa2485be4891-4 deleted file mode 100644 index b0c776bd4d..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/1ec95e347fd522e6385b5091aa81aa2485be4891-4 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/1fbfa5d214060d2a0905846a589fd6f78d411451-4 b/tests/fuzzers/txfetcher/corpus/1fbfa5d214060d2a0905846a589fd6f78d411451-4 deleted file mode 100644 index 75de835c98..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/1fbfa5d214060d2a0905846a589fd6f78d411451-4 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/1fd84ee194e791783a7f18f0a6deab8efe05fc04-2 b/tests/fuzzers/txfetcher/corpus/1fd84ee194e791783a7f18f0a6deab8efe05fc04-2 deleted file mode 100644 index 3b6d2560ae..0000000000 --- a/tests/fuzzers/txfetcher/corpus/1fd84ee194e791783a7f18f0a6deab8efe05fc04-2 +++ /dev/null @@ -1 +0,0 @@ -& \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/21e76b9fca21d94d97f860c1c82f40697a83471b-8 b/tests/fuzzers/txfetcher/corpus/21e76b9fca21d94d97f860c1c82f40697a83471b-8 deleted file mode 100644 index 1d4620f49f..0000000000 --- a/tests/fuzzers/txfetcher/corpus/21e76b9fca21d94d97f860c1c82f40697a83471b-8 +++ /dev/null @@ -1,3 +0,0 @@ -DtQvfQ+MULKZTXk78c -/fWkpxlQQ/+hgNzVtx9vWgJsafG7b0dA4AFjwVbFLmQcj2PprIMmPNQrooX -L \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/220a87fed0c92474923054094eb7aff14289cf5e-4 b/tests/fuzzers/txfetcher/corpus/220a87fed0c92474923054094eb7aff14289cf5e-4 deleted file mode 100644 index 175f74fd5a..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/220a87fed0c92474923054094eb7aff14289cf5e-4 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/23ddcd66aa92fe3d78b7f5b6e7cddb1b55c5f5df-3 b/tests/fuzzers/txfetcher/corpus/23ddcd66aa92fe3d78b7f5b6e7cddb1b55c5f5df-3 deleted file mode 100644 index 95892c7b00..0000000000 --- a/tests/fuzzers/txfetcher/corpus/23ddcd66aa92fe3d78b7f5b6e7cddb1b55c5f5df-3 +++ /dev/null @@ -1,12 +0,0 @@ -4txjeVE6myuDqkM/uGlfjb9 -SjY1bIw4iA5sBBZzHi3z0h1YV8QPuxEbi4nW91IJm2gsvvZeIrCHS3l6afab4pZB -l2+XsDlrKBxKKtD1rGxlG4jncdabFn9gvLZad2bSysqz/qTAUSTvqJQIDAQAB -AoGAGRzwwXvBOAy5tM/uV6e+Zf6aZzus1s1Y1ClbjbE6HXbnWWF/wbZGOpet -3Z4vD6Mc7pLryzTQIVdfQbRc6+MUVeLKZaTXtdZru+Jk70PJJqFk541aEw+mMogY/xEcfbWd6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nk+gN4H -qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQ2PprIMPcQroo8vpjSHg1Ev14KxmQeDydfsgeuN8UBESJwm7F -UtuL7Xvjw50pNEbc6Iuyty4QJA21su4sjXNueLQphy2U -fQtuUE9txblTu14qN7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xlp/DoCzjA0CQQDU -y2ptGsuSmgUtWj3NM9xuwYPm+Z/F84K6ARYiZPYj1oGUFfYAVVxtI -qyBnu3X9pfLZOAkEAlT4R5Yl6cJQYZHOde3JEhNRcVFMO8dJFo -f9Oeos0UUhgiDkQxdEwLjQf7lJJz5OtwC= --NRSA TESINGKEY-Q_ \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/2441d249faf9a859e38c49f6e305b394280c6ea5-1 b/tests/fuzzers/txfetcher/corpus/2441d249faf9a859e38c49f6e305b394280c6ea5-1 deleted file mode 100644 index d76207e992..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/2441d249faf9a859e38c49f6e305b394280c6ea5-1 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/2da1f0635e11283b1927974f418aadd8837ad31e-7 b/tests/fuzzers/txfetcher/corpus/2da1f0635e11283b1927974f418aadd8837ad31e-7 deleted file mode 100644 index 73ae705701..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/2da1f0635e11283b1927974f418aadd8837ad31e-7 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/2e1853fbf8efe40098b1583224fe3b5f335e7037-6 b/tests/fuzzers/txfetcher/corpus/2e1853fbf8efe40098b1583224fe3b5f335e7037-6 deleted file mode 100644 index 692981e614..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/2e1853fbf8efe40098b1583224fe3b5f335e7037-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/2f25490dc49c103d653843ed47324b310ee7105e-7 b/tests/fuzzers/txfetcher/corpus/2f25490dc49c103d653843ed47324b310ee7105e-7 deleted file mode 100644 index 5cf7da75df..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/2f25490dc49c103d653843ed47324b310ee7105e-7 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/30494b85bb60ad7f099fa49d427007a761620d8f-5 b/tests/fuzzers/txfetcher/corpus/30494b85bb60ad7f099fa49d427007a761620d8f-5 deleted file mode 100644 index 7ff9d39752..0000000000 --- a/tests/fuzzers/txfetcher/corpus/30494b85bb60ad7f099fa49d427007a761620d8f-5 +++ /dev/null @@ -1,10 +0,0 @@ -jXbnWWF/wbZGOpet -3Zm4vD6MXc7jpTLryzTQIvVdfQbRc6+MUVeLKwZatTXtdZrhu+Jk7hx0nTPy8Jcb -uJqFk541aEw+mMogY/xEcfbWd6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nk+hgN4H -qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQcj2PprIMmPcQrooz8vp -jy4SHEg1AkEA/v13/5M47K9vCxb8QeD/asydfsgS5TeuNi8DoUBEmiSJwma7FXY -fFUtxuvL7XvjwjN5B30pNEbc6Iuyt7y4MQJBAIt21su4b3sjXNueLKH85Q+phy2U -fQtuUE9txblTu14q3N7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xl/DoCzjA0CQQDU -y2ptGsuSmgUtWj3NM9xuwYPm+Z/F84K6+ARYiZ6Yj013sovGKUFfYAqVXVlxtIX -qyUBnu3Xh9ps8ZfjLZO7BAkEAlT4R5Yl6cGhaJQYZHOde3JEMhNRcVFMO8dDaFeo -f9Oeos0UotgiDktdQHxdNEwLjQfl \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/316024ca3aaf09c1de5258733ff5fe3d799648d3-4 b/tests/fuzzers/txfetcher/corpus/316024ca3aaf09c1de5258733ff5fe3d799648d3-4 deleted file mode 100644 index 61f7d78f34..0000000000 --- a/tests/fuzzers/txfetcher/corpus/316024ca3aaf09c1de5258733ff5fe3d799648d3-4 +++ /dev/null @@ -1,15 +0,0 @@ -^oȗ----BEGIN RA TTING KEY----- -IIXgIBAAKBQDuLnQI3mDgey3VBzWnB2L39JUU4txjeVE6myuDqkM/uGlfjb9 -SjY1bIw4iA5sBBZzHi3z0h1YV8QPuxEbi4nW91IJmgsvvZhrCHSl6afab4pZB -l2+XsDulrKBxKKtD1rGxlG4LjcdabF9gvLZad2bSysqz/qTAUStTvqJQDAQAB -AoGAGRzwwir7XvBOAy5tM/uV6e+Zf6anZzus1s1Y1ClbjbE6HXbnWWF/wbZGOpet -3Z4vD6MXc7jpTLryzTQIvVdfQbRc6+MUVeLKwZatTXtdZrhu+Jk7hx0nTPy8Jcb -uJqFk541aEw+mMogY/xEcfbWd6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nk+hgN4H -qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQcj2PprIMmPcQrooz8vp -jy4SHEg1AkEA/v13/5M47K9vCxmb8QeD/asydfsgS5TeuNi8DoUBEmiSJwma7FXY -fFUtxuvL7XvjwjN5B30pNEbc6Iuyt7y4MQJBAIt21su4b3sjXNueLKH85Q+phy2U -fQtuUE9txblTu14q3N7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xlp/DoCzjA0CQQDU -y2ptGsuSmgUtWj3NM9xuwYPm+Z/F84K6+ARYiZ6PYj043sovGKUFfYAqVXVlxtIX -qyUBnu3X9ps8ZfjLZO7BAkEAlT4R5Yl6cGhaJQYZHOde3JEMhNRcVFMO8dJDaFeo -f9Oeos0UUothgiDktdQHxdNEwLjQf7lJJBzV+5OtwswCWA== ------END RSA TESTING KEY-----Q_ \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/32a089e2c439a91f4c1b67a13d52429bcded0dd9-7 b/tests/fuzzers/txfetcher/corpus/32a089e2c439a91f4c1b67a13d52429bcded0dd9-7 deleted file mode 100644 index a986a9d8e7..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/32a089e2c439a91f4c1b67a13d52429bcded0dd9-7 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/33ec1dc0bfeb93d16edee3c07125fec6ac1aa17d-2 b/tests/fuzzers/txfetcher/corpus/33ec1dc0bfeb93d16edee3c07125fec6ac1aa17d-2 deleted file mode 100644 index d41771b86c..0000000000 --- a/tests/fuzzers/txfetcher/corpus/33ec1dc0bfeb93d16edee3c07125fec6ac1aa17d-2 +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/37a0d207700b52caa005ec8aeb344dcb13150ed2-5 b/tests/fuzzers/txfetcher/corpus/37a0d207700b52caa005ec8aeb344dcb13150ed2-5 deleted file mode 100644 index 2f09c6e28f..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/37a0d207700b52caa005ec8aeb344dcb13150ed2-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/382f59c66d0ddb6747d3177263279789ca15c2db-5 b/tests/fuzzers/txfetcher/corpus/382f59c66d0ddb6747d3177263279789ca15c2db-5 deleted file mode 100644 index 84441ac374..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/382f59c66d0ddb6747d3177263279789ca15c2db-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/3a010483a4ad8d7215447ce27e0fac3791235c99-4 b/tests/fuzzers/txfetcher/corpus/3a010483a4ad8d7215447ce27e0fac3791235c99-4 deleted file mode 100644 index 28f5d99b98..0000000000 --- a/tests/fuzzers/txfetcher/corpus/3a010483a4ad8d7215447ce27e0fac3791235c99-4 +++ /dev/null @@ -1,7 +0,0 @@ - -lGAGRzwwir7XvBOAy5tM/uV6e+Zf6anZzus1s1Y1ClbjbE6HXbnWWF/wbZGOpet -3Zm4vD6MXc7jpTLryzTQIvVdfQbRc6+MUVeLKwZatTXtdZrhu+Jk7hx0nTPy8Jcb -uJqFk541aEw+mMogY/xEcfbWd6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nk+hgN4H -qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQcj2PprIMmPcQrooz8vp -jy4SHEg1AkEA/v13/5M47K9vCxmb8QeD/asydfsgS5TeuNi8DoUBEmiSJwma7FXY -fFUtxuvL7XvjwjN5 \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/3a3b717fcfe7ffb000b906e5a76f32248a576bf7-6 b/tests/fuzzers/txfetcher/corpus/3a3b717fcfe7ffb000b906e5a76f32248a576bf7-6 deleted file mode 100644 index 022de3c61d..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/3a3b717fcfe7ffb000b906e5a76f32248a576bf7-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/3c37f6d58b8029971935f127f53e6aaeba558445-6 b/tests/fuzzers/txfetcher/corpus/3c37f6d58b8029971935f127f53e6aaeba558445-6 deleted file mode 100644 index 9f3bf093ad..0000000000 --- a/tests/fuzzers/txfetcher/corpus/3c37f6d58b8029971935f127f53e6aaeba558445-6 +++ /dev/null @@ -1,2 +0,0 @@ -w�€��������� � -� � � ������������������ �!�"�#�$�%�&�'�(�)�*�+�,�-�.�/0 \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/3c73b63bafa9f535c882ec17189adaf02b58f432-6 b/tests/fuzzers/txfetcher/corpus/3c73b63bafa9f535c882ec17189adaf02b58f432-6 deleted file mode 100644 index 0dfbc46993..0000000000 --- a/tests/fuzzers/txfetcher/corpus/3c73b63bafa9f535c882ec17189adaf02b58f432-6 +++ /dev/null @@ -1 +0,0 @@ -LvhaJQHOe3EhRcdaFofeoogkjQfJB \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/3d11500c4f66b20c73bbdfb1a7bddd7bbf92b29c-5 b/tests/fuzzers/txfetcher/corpus/3d11500c4f66b20c73bbdfb1a7bddd7bbf92b29c-5 deleted file mode 100644 index b19fc7f458..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/3d11500c4f66b20c73bbdfb1a7bddd7bbf92b29c-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/3d8b5bf36c80d6f65802280039f85421f32b5055-6 b/tests/fuzzers/txfetcher/corpus/3d8b5bf36c80d6f65802280039f85421f32b5055-6 deleted file mode 100644 index eacd269f31..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/3d8b5bf36c80d6f65802280039f85421f32b5055-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/3f99c546a3962256176d566c19e3fffb62072078-1 b/tests/fuzzers/txfetcher/corpus/3f99c546a3962256176d566c19e3fffb62072078-1 deleted file mode 100644 index 9e90183d6b..0000000000 --- a/tests/fuzzers/txfetcher/corpus/3f99c546a3962256176d566c19e3fffb62072078-1 +++ /dev/null @@ -1 +0,0 @@ -&^o \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/408ec46539af27acd82b3d01e863597030882458-8 b/tests/fuzzers/txfetcher/corpus/408ec46539af27acd82b3d01e863597030882458-8 deleted file mode 100644 index 65d55437e5..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/408ec46539af27acd82b3d01e863597030882458-8 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/436154e5bb6487673f6642e6d2a582c01b083c08-8 b/tests/fuzzers/txfetcher/corpus/436154e5bb6487673f6642e6d2a582c01b083c08-8 deleted file mode 100644 index 28e519c125..0000000000 --- a/tests/fuzzers/txfetcher/corpus/436154e5bb6487673f6642e6d2a582c01b083c08-8 +++ /dev/null @@ -1 +0,0 @@ -apfffffffffffffffffffffffffffffffebadce6f48a0_3bbfd2364 \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/45f565cd14b8de1ba2e925047ce776c2682b4b8d-3 b/tests/fuzzers/txfetcher/corpus/45f565cd14b8de1ba2e925047ce776c2682b4b8d-3 deleted file mode 100644 index 9f03a095b9..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/45f565cd14b8de1ba2e925047ce776c2682b4b8d-3 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/4a0a12f5b033c8c160cc3b5133692ea1e92c6cdf-7 b/tests/fuzzers/txfetcher/corpus/4a0a12f5b033c8c160cc3b5133692ea1e92c6cdf-7 deleted file mode 100644 index e50b5494c9..0000000000 --- a/tests/fuzzers/txfetcher/corpus/4a0a12f5b033c8c160cc3b5133692ea1e92c6cdf-7 +++ /dev/null @@ -1,3 +0,0 @@ -DtQvfQ+MULKZTXk78c -/fWkpxlyEQQ/+hgNzVtx9vWgJsafG7b0dA4AFjwVbFLmQcj2PprIMmPNQg1Ak/7KCxmDgS5TDEmSJwFX -txLjbt4xTgeXVlXsjLZ \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/550f15ef65230cc4dcfab7fea67de212d9212ff8-8 b/tests/fuzzers/txfetcher/corpus/550f15ef65230cc4dcfab7fea67de212d9212ff8-8 deleted file mode 100644 index 34005f43cb..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/550f15ef65230cc4dcfab7fea67de212d9212ff8-8 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/5552213d659fef900a194c52718ffeffdc72d043-3 b/tests/fuzzers/txfetcher/corpus/5552213d659fef900a194c52718ffeffdc72d043-3 deleted file mode 100644 index 7346ff1955..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/5552213d659fef900a194c52718ffeffdc72d043-3 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/5570ef82893a9b9b9158572d43a7de7537121d2d-1 b/tests/fuzzers/txfetcher/corpus/5570ef82893a9b9b9158572d43a7de7537121d2d-1 deleted file mode 100644 index feffcebca0..0000000000 --- a/tests/fuzzers/txfetcher/corpus/5570ef82893a9b9b9158572d43a7de7537121d2d-1 +++ /dev/null @@ -1 +0,0 @@ -�ٯ0,1,2,3,4,5,6,7,-3420794409,(2,a) \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/5e10f734f8af4116fbd164d96eec67aa53e6228c-5 b/tests/fuzzers/txfetcher/corpus/5e10f734f8af4116fbd164d96eec67aa53e6228c-5 deleted file mode 100644 index 0eacd0b59a..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/5e10f734f8af4116fbd164d96eec67aa53e6228c-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/608200b402488b3989ec8ec5f4190ccb537b8ea4-4 b/tests/fuzzers/txfetcher/corpus/608200b402488b3989ec8ec5f4190ccb537b8ea4-4 deleted file mode 100644 index d37b018515..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/608200b402488b3989ec8ec5f4190ccb537b8ea4-4 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/61e89c3fbdf9eff74bd250ea73cc2e61f8ca0d97-5 b/tests/fuzzers/txfetcher/corpus/61e89c3fbdf9eff74bd250ea73cc2e61f8ca0d97-5 deleted file mode 100644 index 155744bccc..0000000000 --- a/tests/fuzzers/txfetcher/corpus/61e89c3fbdf9eff74bd250ea73cc2e61f8ca0d97-5 +++ /dev/null @@ -1 +0,0 @@ -88242871'392752200424491531672177074144720616417147514758635765020556616 \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/62817a48c78fbf2c12fcdc5ca58e2ca60c43543a-7 b/tests/fuzzers/txfetcher/corpus/62817a48c78fbf2c12fcdc5ca58e2ca60c43543a-7 deleted file mode 100644 index 795608a789..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/62817a48c78fbf2c12fcdc5ca58e2ca60c43543a-7 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/6782da8f1a432a77306d60d2ac2470c35b98004f-3 b/tests/fuzzers/txfetcher/corpus/6782da8f1a432a77306d60d2ac2470c35b98004f-3 deleted file mode 100644 index f44949e6ae..0000000000 --- a/tests/fuzzers/txfetcher/corpus/6782da8f1a432a77306d60d2ac2470c35b98004f-3 +++ /dev/null @@ -1 +0,0 @@ -21888242871'392752200424452601091531672177074144720616417147514758635765020556616 \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/68fb55290cb9d6da5b259017c34bcecf96c944aa-5 b/tests/fuzzers/txfetcher/corpus/68fb55290cb9d6da5b259017c34bcecf96c944aa-5 deleted file mode 100644 index 23d905b827..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/68fb55290cb9d6da5b259017c34bcecf96c944aa-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/6a5059bc86872526241d21ab5dae9f0afd3b9ae1-3 b/tests/fuzzers/txfetcher/corpus/6a5059bc86872526241d21ab5dae9f0afd3b9ae1-3 deleted file mode 100644 index b71d5dff51..0000000000 --- a/tests/fuzzers/txfetcher/corpus/6a5059bc86872526241d21ab5dae9f0afd3b9ae1-3 +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/717928e0e2d478c680c6409b173552ca98469ba5-6 b/tests/fuzzers/txfetcher/corpus/717928e0e2d478c680c6409b173552ca98469ba5-6 deleted file mode 100644 index dce5106115..0000000000 --- a/tests/fuzzers/txfetcher/corpus/717928e0e2d478c680c6409b173552ca98469ba5-6 +++ /dev/null @@ -1 +0,0 @@ -LvhaJcdaFofenogkjQfJB \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/71d22f25419543e437f249ca437823b87ac926b1-6 b/tests/fuzzers/txfetcher/corpus/71d22f25419543e437f249ca437823b87ac926b1-6 deleted file mode 100644 index d07a6c2f32..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/71d22f25419543e437f249ca437823b87ac926b1-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/7312a0f31ae5d773ed4fd74abc7521eb14754683-8 b/tests/fuzzers/txfetcher/corpus/7312a0f31ae5d773ed4fd74abc7521eb14754683-8 deleted file mode 100644 index 3593ce2e19..0000000000 --- a/tests/fuzzers/txfetcher/corpus/7312a0f31ae5d773ed4fd74abc7521eb14754683-8 +++ /dev/null @@ -1,2 +0,0 @@ -DtQvfQ+MULKZTXk78c -/fWkpxlyEQQ/+hgNzVtx9vWgJsafG7b0dA4AFjwVbFLmQcj2PprIMmPNQg1AkS5TDEmSJwFVlXsjLZ \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/76e413a50dc8861e3756e556f796f1737bec2675-4 b/tests/fuzzers/txfetcher/corpus/76e413a50dc8861e3756e556f796f1737bec2675-4 deleted file mode 100644 index 623fcf9601..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/76e413a50dc8861e3756e556f796f1737bec2675-4 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/78480977d5c07386b06e9b37f5c82f5ed86c2f09-3 b/tests/fuzzers/txfetcher/corpus/78480977d5c07386b06e9b37f5c82f5ed86c2f09-3 deleted file mode 100644 index e92863a1c7..0000000000 --- a/tests/fuzzers/txfetcher/corpus/78480977d5c07386b06e9b37f5c82f5ed86c2f09-3 +++ /dev/null @@ -1,14 +0,0 @@ - TESTING KEY----- -MIICXgIBAAKBgQDuLnQAI3mDgey3VBzWnB2L39JUU4txjeVE6myuDqkM/uGlfjb9 -SjY1bIw4iAJm2gsvvZhIrCHS3l6afab4pZB -l2+XsDulrKBxKKtD1rGxlG4LjncdabFn9gvLZad2bSysqz/qTAUStTvqJQIDAQAB -AoGAGRzwwir7XvBOAy5tM/uV6e+Zf6anZzus1s1Y1ClbjbE6HXbnWWF/wbZGOpet -3Zm4vD6MXc7jpTLryzTQIvVdfQbRc6+MUVeLKwZatTXtdZrhu+Jk7hx0nTPy8Jcb -uJqFk541aEw+mMogY/xEcfbWd6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nk+hgN4H -qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQcj2PprIMmPcQrooz8vp -jy4SHEg1AkEA/v13/5M47K9vCxmb8QeD/asydfsgS5TeuNi8DoUBEmiSJwma7FXY -fFUtxuvL7XvjwjN5B30pNEbc6Iuyt7y4MQJBAIt21su4b3sjXNueLKH85Q+phy2U -fQtuUE9txblTu14q3N7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xl/DoCzjA0CQQDU -y2ptGsuSmgUtWj3NM9xuwYPm+Z/F84K6+ARYiZ6PYj013sovGKUFfYAqVXVlxtIX -qyUBnu3Xh9ps8ZfjLZO7BAkEAlT4R5Yl6cGhaJQYZHOde3JEMhNRcVFMO8dDaFeo -f9Oeos0UotgiDktdQHxdNEwLjQflJJBzV+5OtwswCA=----EN RATESTI EY-----Q \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/7a113cd3c178934cdb64353af86d51462d7080a4-5 b/tests/fuzzers/txfetcher/corpus/7a113cd3c178934cdb64353af86d51462d7080a4-5 deleted file mode 100644 index 16818128ae..0000000000 --- a/tests/fuzzers/txfetcher/corpus/7a113cd3c178934cdb64353af86d51462d7080a4-5 +++ /dev/null @@ -1,10 +0,0 @@ -l6afab4pZB -l2+XsDlrKBxKKtDrGxlG4LjncdabFn9gvLZad2bSysqz/qTAUStTtqJQIDAQAB -AoGAGRzwwir7XvBOAy5tuV6ef6anZzus1s1Y1Clb6HbnWWF/wbZGOpet -3m4vD6MXc7jpTLryzTQIvVdfQbRc6+MUVeLKZTXtdZrh+k7hx0nTP8Jcb -uqFk541awmMogY/EfbWd6IOkp+4xqjlFBEDytgbIECQQDvH/6nk+hgN4H -qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQcj2PprIMmPcQrooz84SHEg1Ak/7KCxmD/sfgS5TeuNi8DoUBEmiSJwm7FX -ftxuvL7XvjwjN5B30pNEbc6Iuyt7y4MQJBAIt21su43sjXNueLKH8+ph2UfQuU9txblTu14q3N7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xl/DoCzjA0CQQDU -y2pGsuSmgUtWj3NM9xuwYPm+Z/F84K6+ARYiZ6PYj13sovGKUFfYAqVXVlxtIoX -qUn3X9ps8ZfjLZO7BAkEAlT4R5Yl6cGhaJQYZHOde3JMhNRcVFMO8dDaFo -f9Oeos0UotgiDktdQHxdNEwLjQlJBz+OtwwA=---E ATTIEY- \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/7ea9f71020f3eb783f743f744eba8d8ca4b2582f-3 b/tests/fuzzers/txfetcher/corpus/7ea9f71020f3eb783f743f744eba8d8ca4b2582f-3 deleted file mode 100644 index 08f5bb99f5..0000000000 --- a/tests/fuzzers/txfetcher/corpus/7ea9f71020f3eb783f743f744eba8d8ca4b2582f-3 +++ /dev/null @@ -1,9 +0,0 @@ - -l2+DulrKBxKKtD1rGxlG4LjncdabFn9gvLZad2bSysqz/qTAUStTvqJQIDAQAB -AoGAGRzwwir7XvBOAy5tM/uV6e+Zf6anZzus1s1Y1ClbjbE6HXbnWWF/wbZGOpet -3Zm4vD6MXc7jpTLryzTQIvVdfQbRc6+MUVeLKwZatTXtdZrhu+Jk7hx0nTPy8Jcb -uJqFk541aEw+mMogY/xEcfbWd6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nk+hgN4H -qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQcj2PprIMmPcQrooz8vp -jy4SHEg1AkEA/v13/5M47K9vCxmb8QeD/asydfsgS5TeuNi8DoUBEmiSJwma7FXY -fFUtxuvL7XvjwjN5B30pNEbc6Iuyt7y4MQJBAIt21su4b3sjXNueLKH85Q+phy2U -fQtuUE9txblTu14q3N7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xlp/DoCzjA0CQQDU diff --git a/tests/fuzzers/txfetcher/corpus/84f8c275f3ffbaf8c32c21782af13de10e7de28b-3 b/tests/fuzzers/txfetcher/corpus/84f8c275f3ffbaf8c32c21782af13de10e7de28b-3 deleted file mode 100644 index 2d6060c406..0000000000 --- a/tests/fuzzers/txfetcher/corpus/84f8c275f3ffbaf8c32c21782af13de10e7de28b-3 +++ /dev/null @@ -1 +0,0 @@ -KKtDlbjVeLKwZatTXtdZrhu+Jk7hx0xxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLQcmPcQETT YQ \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/85dfe7ddee0e52aa19115c0ebb9ed28a14e488c6-5 b/tests/fuzzers/txfetcher/corpus/85dfe7ddee0e52aa19115c0ebb9ed28a14e488c6-5 deleted file mode 100644 index 9b6fe78029..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/85dfe7ddee0e52aa19115c0ebb9ed28a14e488c6-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/87bba5b1e3da38fed8cb5a9bc5c8baa819e83d05-5 b/tests/fuzzers/txfetcher/corpus/87bba5b1e3da38fed8cb5a9bc5c8baa819e83d05-5 deleted file mode 100644 index ef091f0be2..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/87bba5b1e3da38fed8cb5a9bc5c8baa819e83d05-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/8a9ebedfbfec584d8b22761e6121dc1ca0248548-4 b/tests/fuzzers/txfetcher/corpus/8a9ebedfbfec584d8b22761e6121dc1ca0248548-4 deleted file mode 100644 index 953be79201..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/8a9ebedfbfec584d8b22761e6121dc1ca0248548-4 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/8ff3bd49f93079e5e1c7f8f2461ba7ee612900c3-5 b/tests/fuzzers/txfetcher/corpus/8ff3bd49f93079e5e1c7f8f2461ba7ee612900c3-5 deleted file mode 100644 index a86a66593b..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/8ff3bd49f93079e5e1c7f8f2461ba7ee612900c3-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/9034aaf45143996a2b14465c352ab0c6fa26b221-2 b/tests/fuzzers/txfetcher/corpus/9034aaf45143996a2b14465c352ab0c6fa26b221-2 deleted file mode 100644 index 9c95a6ba6a..0000000000 --- a/tests/fuzzers/txfetcher/corpus/9034aaf45143996a2b14465c352ab0c6fa26b221-2 +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/92cefdc6251d04896349a464b29be03d6bb04c3d-2 b/tests/fuzzers/txfetcher/corpus/92cefdc6251d04896349a464b29be03d6bb04c3d-2 deleted file mode 100644 index 9b78e45707..0000000000 --- a/tests/fuzzers/txfetcher/corpus/92cefdc6251d04896349a464b29be03d6bb04c3d-2 +++ /dev/null @@ -1 +0,0 @@ -39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319 \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/9613e580ccb69df7c9074f0e2f6886ac6b34ca55-5 b/tests/fuzzers/txfetcher/corpus/9613e580ccb69df7c9074f0e2f6886ac6b34ca55-5 deleted file mode 100644 index 681adc6a9c..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/9613e580ccb69df7c9074f0e2f6886ac6b34ca55-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/98afc8970a680fdc4aee0b5d48784f650c566b75-6 b/tests/fuzzers/txfetcher/corpus/98afc8970a680fdc4aee0b5d48784f650c566b75-6 deleted file mode 100644 index c82defc243..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/98afc8970a680fdc4aee0b5d48784f650c566b75-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/9dfc92f4ca2ece0167096fca6751ff314765f08b-8 b/tests/fuzzers/txfetcher/corpus/9dfc92f4ca2ece0167096fca6751ff314765f08b-8 deleted file mode 100644 index be75c25fec..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/9dfc92f4ca2ece0167096fca6751ff314765f08b-8 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/9ebcbbfdaf0e98c87652e57226a4d8a35170c67d-4 b/tests/fuzzers/txfetcher/corpus/9ebcbbfdaf0e98c87652e57226a4d8a35170c67d-4 deleted file mode 100644 index ab036767db..0000000000 --- a/tests/fuzzers/txfetcher/corpus/9ebcbbfdaf0e98c87652e57226a4d8a35170c67d-4 +++ /dev/null @@ -1,5 +0,0 @@ -l2+DulrKBxKKtD1rGxlG4LjncdabFn9gvLZad2bSysqz/qTAUStTvqJQIDAQAB -AoGAGRzwwir7XvBOAy5tM/uV6e+Zf6anZzus1s1Y1ClbjbE6HXbnWWF/wbZGOpwVbFLmQet -3Zm4vD6MXc7jpTLryzTQIvVdfQbRc6+MUVeLKwZatTXtdZrhu+Jk7hx0nTPy8Jcb -uJqFk541aEw+mMogY/xEcfbWd6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nk+hgN4H -qzzVtxxr397vWrjr \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/9ff520eb8b8319a5fdafbe4d1cbb02a75058d93b-7 b/tests/fuzzers/txfetcher/corpus/9ff520eb8b8319a5fdafbe4d1cbb02a75058d93b-7 deleted file mode 100644 index d91a13138c..0000000000 --- a/tests/fuzzers/txfetcher/corpus/9ff520eb8b8319a5fdafbe4d1cbb02a75058d93b-7 +++ /dev/null @@ -1,2 +0,0 @@ -&w�€��������� � -� � � ����������������� �!�"�#�$�%�&�'�(�)�*�+�,�-�.�/0 \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/a0b57a12e25ac5adcedb2a5c45915f0f62aee869-4 b/tests/fuzzers/txfetcher/corpus/a0b57a12e25ac5adcedb2a5c45915f0f62aee869-4 deleted file mode 100644 index 78243163a8..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/a0b57a12e25ac5adcedb2a5c45915f0f62aee869-4 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/a2684adccf16e036b051c12f283734fa803746e8-6 b/tests/fuzzers/txfetcher/corpus/a2684adccf16e036b051c12f283734fa803746e8-6 deleted file mode 100644 index 4e12af2da8..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/a2684adccf16e036b051c12f283734fa803746e8-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/a37305974cf477ecfe65fa92f37b1f51dea25910-4 b/tests/fuzzers/txfetcher/corpus/a37305974cf477ecfe65fa92f37b1f51dea25910-4 deleted file mode 100644 index 75cb14e8d9..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/a37305974cf477ecfe65fa92f37b1f51dea25910-4 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/a7eb43926bd14b1f62a66a33107776e487434d32-7 b/tests/fuzzers/txfetcher/corpus/a7eb43926bd14b1f62a66a33107776e487434d32-7 deleted file mode 100644 index 88e6127355..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/a7eb43926bd14b1f62a66a33107776e487434d32-7 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/a8f7c254eb64a40fd2a77b79979c7bbdac6a760c-4 b/tests/fuzzers/txfetcher/corpus/a8f7c254eb64a40fd2a77b79979c7bbdac6a760c-4 deleted file mode 100644 index da61777c22..0000000000 --- a/tests/fuzzers/txfetcher/corpus/a8f7c254eb64a40fd2a77b79979c7bbdac6a760c-4 +++ /dev/null @@ -1,2 +0,0 @@ -lxtIX -qyU3X9ps8ZfjLZ45l6cGhaJQYZHOde3JEMhNRcVFMO8dJDaFe \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/a9a8f287d6af24e47d8db468e8f967aa44fb5a1f-7 b/tests/fuzzers/txfetcher/corpus/a9a8f287d6af24e47d8db468e8f967aa44fb5a1f-7 deleted file mode 100644 index 7811921b79..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/a9a8f287d6af24e47d8db468e8f967aa44fb5a1f-7 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/aa7444d8e326158046862590a0db993c07aef372-7 b/tests/fuzzers/txfetcher/corpus/aa7444d8e326158046862590a0db993c07aef372-7 deleted file mode 100644 index 870e12ffbc..0000000000 --- a/tests/fuzzers/txfetcher/corpus/aa7444d8e326158046862590a0db993c07aef372-7 +++ /dev/null @@ -1 +0,0 @@ -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000@0000000000000 \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/ae4593626d8796e079a358c2395a4f6c9ddd6a44-6 b/tests/fuzzers/txfetcher/corpus/ae4593626d8796e079a358c2395a4f6c9ddd6a44-6 deleted file mode 100644 index 845deedd0e..0000000000 --- a/tests/fuzzers/txfetcher/corpus/ae4593626d8796e079a358c2395a4f6c9ddd6a44-6 +++ /dev/null @@ -1,8 +0,0 @@ -9pmM gY/xEcfbWd6IOkp+4xqjlFLBEDytgbparsing /E6nk+hgN4H -qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLmQcj2PprLANGcQrooz8vp -jy4SHEg1AkEA/v13/@M47K9vCxb8QeD/asydfsgS5TeuNi8DoUBEmiSJwma7FXY -fFUtxuvL7XvjwjN5B30pNEbc6Iuyt7y4MQJBAIt21su4b3sjXNueLKH85Q+phy2U -fQtuUE9txblTu14q3N7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xl/DoCz� jA0CQQDU -y2ptGsuSmgUtWj3NM9xuwYPm+Z/F84K6+ARYiZ6Yj013sovGKUFfYAqVXVlxtIX -qyUBnu3Xh9ps8ZfjLZO7BAkEAlT4R5Yl6cGhaJQYFZHOde3JEMhNRcVFMO8dDaFeo -f9Oeos0Uot \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/b2942d4413a66939cda7db93020dee79eb17788c-9 b/tests/fuzzers/txfetcher/corpus/b2942d4413a66939cda7db93020dee79eb17788c-9 deleted file mode 100644 index 10aca65121..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/b2942d4413a66939cda7db93020dee79eb17788c-9 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/b4614117cdfd147d38f4e8a4d85f5a2bb99a6a4f-5 b/tests/fuzzers/txfetcher/corpus/b4614117cdfd147d38f4e8a4d85f5a2bb99a6a4f-5 deleted file mode 100644 index af69eef9b0..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/b4614117cdfd147d38f4e8a4d85f5a2bb99a6a4f-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/b631ef3291fa405cd6517d11f4d1b9b6d02912d4-2 b/tests/fuzzers/txfetcher/corpus/b631ef3291fa405cd6517d11f4d1b9b6d02912d4-2 deleted file mode 100644 index a6b8858b40..0000000000 --- a/tests/fuzzers/txfetcher/corpus/b631ef3291fa405cd6517d11f4d1b9b6d02912d4-2 +++ /dev/null @@ -1 +0,0 @@ -&o \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/b7a91e338cc11f50ebdb2c414610efc4d5be3137-4 b/tests/fuzzers/txfetcher/corpus/b7a91e338cc11f50ebdb2c414610efc4d5be3137-4 deleted file mode 100644 index 9709a1fcb8..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/b7a91e338cc11f50ebdb2c414610efc4d5be3137-4 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/b858cb282617fb0956d960215c8e84d1ccf909c6-2 b/tests/fuzzers/txfetcher/corpus/b858cb282617fb0956d960215c8e84d1ccf909c6-2 deleted file mode 100644 index 0519ecba6e..0000000000 --- a/tests/fuzzers/txfetcher/corpus/b858cb282617fb0956d960215c8e84d1ccf909c6-2 +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/bc9d570aacf3acd39600feda8e72a293a4667da4-1 b/tests/fuzzers/txfetcher/corpus/bc9d570aacf3acd39600feda8e72a293a4667da4-1 deleted file mode 100644 index aab27c5909..0000000000 --- a/tests/fuzzers/txfetcher/corpus/bc9d570aacf3acd39600feda8e72a293a4667da4-1 +++ /dev/null @@ -1 +0,0 @@ -� \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/be7eed35b245b5d5d2adcdb4c67f07794eb86b24-3 b/tests/fuzzers/txfetcher/corpus/be7eed35b245b5d5d2adcdb4c67f07794eb86b24-3 deleted file mode 100644 index 47c996d33f..0000000000 --- a/tests/fuzzers/txfetcher/corpus/be7eed35b245b5d5d2adcdb4c67f07794eb86b24-3 +++ /dev/null @@ -1,2 +0,0 @@ -4LZmbRc6+MUVeLKXtdZr+Jk7hhgN4H -qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLQcmPcQ SN_ \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/c010b0cd70c7edbc5bd332fc9e2e91c6a1cbcdc4-5 b/tests/fuzzers/txfetcher/corpus/c010b0cd70c7edbc5bd332fc9e2e91c6a1cbcdc4-5 deleted file mode 100644 index 474f14d89b..0000000000 --- a/tests/fuzzers/txfetcher/corpus/c010b0cd70c7edbc5bd332fc9e2e91c6a1cbcdc4-5 +++ /dev/null @@ -1,4 +0,0 @@ - -Xc7jpTLryzTQIvVdfQbRc6+MUVeLKwZatTXtdZrhu+Jk7hx0nTPy8Jcb -uJqFk541aEw+mMogY/xEcfbWd6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nhgN4H -qzzVtxx7vWrjrIgPbJpvfb \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/c1690698607eb0f4c4244e9f9629968be4beb6bc-8 b/tests/fuzzers/txfetcher/corpus/c1690698607eb0f4c4244e9f9629968be4beb6bc-8 deleted file mode 100644 index d184a2d8a4..0000000000 --- a/tests/fuzzers/txfetcher/corpus/c1690698607eb0f4c4244e9f9629968be4beb6bc-8 +++ /dev/null @@ -1,2 +0,0 @@ -&Ƚ�� � -� � � ����������������� �!�"�#�$�%�&�'�(�)�*�+�,�-�.�/0 \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/c1f435e4f53a9a17578d9e8c4789860f962a1379-6 b/tests/fuzzers/txfetcher/corpus/c1f435e4f53a9a17578d9e8c4789860f962a1379-6 deleted file mode 100644 index f2a68ec3de..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/c1f435e4f53a9a17578d9e8c4789860f962a1379-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/c298a75334c3acf04bd129a8867447a25c8bacf8-7 b/tests/fuzzers/txfetcher/corpus/c298a75334c3acf04bd129a8867447a25c8bacf8-7 deleted file mode 100644 index 0b437f2260..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/c298a75334c3acf04bd129a8867447a25c8bacf8-7 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/c42287c7d225e530e822f23bbbba6819a9e48f38-6 b/tests/fuzzers/txfetcher/corpus/c42287c7d225e530e822f23bbbba6819a9e48f38-6 deleted file mode 100644 index 91818f5634..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/c42287c7d225e530e822f23bbbba6819a9e48f38-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/c4cdbb891f3ee76476b7375d5ed51691fed95421-10 b/tests/fuzzers/txfetcher/corpus/c4cdbb891f3ee76476b7375d5ed51691fed95421-10 deleted file mode 100644 index e365cc5262..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/c4cdbb891f3ee76476b7375d5ed51691fed95421-10 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/cc9572d72dfa2937074b1766dcbcff9cc58d1137-4 b/tests/fuzzers/txfetcher/corpus/cc9572d72dfa2937074b1766dcbcff9cc58d1137-4 deleted file mode 100644 index b72a78f529..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/cc9572d72dfa2937074b1766dcbcff9cc58d1137-4 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/cd1d73b4e101bc7b979e3f6f135cb12d4594d348-5 b/tests/fuzzers/txfetcher/corpus/cd1d73b4e101bc7b979e3f6f135cb12d4594d348-5 deleted file mode 100644 index 3079de5557..0000000000 --- a/tests/fuzzers/txfetcher/corpus/cd1d73b4e101bc7b979e3f6f135cb12d4594d348-5 +++ /dev/null @@ -1 +0,0 @@ -822452601031714757585602556 \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/d0acdc8fca32bbd58d368eeac3bd9eaa46f59d27-5 b/tests/fuzzers/txfetcher/corpus/d0acdc8fca32bbd58d368eeac3bd9eaa46f59d27-5 deleted file mode 100644 index 794d5d86c6..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/d0acdc8fca32bbd58d368eeac3bd9eaa46f59d27-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/d0e43b715fd00953f7bdd6dfad95811985e81396-4 b/tests/fuzzers/txfetcher/corpus/d0e43b715fd00953f7bdd6dfad95811985e81396-4 deleted file mode 100644 index 742db5fb3b..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/d0e43b715fd00953f7bdd6dfad95811985e81396-4 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/d925fbd22c8bc0de34d6a9d1258ce3d2928d0927-8 b/tests/fuzzers/txfetcher/corpus/d925fbd22c8bc0de34d6a9d1258ce3d2928d0927-8 deleted file mode 100644 index 5920dfe601..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/d925fbd22c8bc0de34d6a9d1258ce3d2928d0927-8 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/d9ba78cb7425724185d5fa300cd5c03aec2683bb-7 b/tests/fuzzers/txfetcher/corpus/d9ba78cb7425724185d5fa300cd5c03aec2683bb-7 deleted file mode 100644 index c4df1cf210..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/d9ba78cb7425724185d5fa300cd5c03aec2683bb-7 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/da39a3ee5e6b4b0d3255bfef95601890afd80709 b/tests/fuzzers/txfetcher/corpus/da39a3ee5e6b4b0d3255bfef95601890afd80709 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/fuzzers/txfetcher/corpus/dcdb7758b87648b5d766b1b341a65834420cf621-7 b/tests/fuzzers/txfetcher/corpus/dcdb7758b87648b5d766b1b341a65834420cf621-7 deleted file mode 100644 index 78cf11ae21..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/dcdb7758b87648b5d766b1b341a65834420cf621-7 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/dd441bd24581332c9ce19e008260a69287aa3cbc-6 b/tests/fuzzers/txfetcher/corpus/dd441bd24581332c9ce19e008260a69287aa3cbc-6 deleted file mode 100644 index 4e0c14006e..0000000000 --- a/tests/fuzzers/txfetcher/corpus/dd441bd24581332c9ce19e008260a69287aa3cbc-6 +++ /dev/null @@ -1,2 +0,0 @@ -Dtf1nWk78c -/fWklyEQQ/+hgNzVtxxmDgS5TDETgeXVlXsjLZ \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/def879fe0fd637a745c00c8f1da340518db8688c-2 b/tests/fuzzers/txfetcher/corpus/def879fe0fd637a745c00c8f1da340518db8688c-2 deleted file mode 100644 index 555752f0ed..0000000000 --- a/tests/fuzzers/txfetcher/corpus/def879fe0fd637a745c00c8f1da340518db8688c-2 +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/df6c30a9781b93bd6d2f5e97e5592d5945210003-7 b/tests/fuzzers/txfetcher/corpus/df6c30a9781b93bd6d2f5e97e5592d5945210003-7 deleted file mode 100644 index 2a7adb093b..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/df6c30a9781b93bd6d2f5e97e5592d5945210003-7 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/dfc1c3a2e3ccdaf6f88c515fd00e8ad08421e431-6 b/tests/fuzzers/txfetcher/corpus/dfc1c3a2e3ccdaf6f88c515fd00e8ad08421e431-6 deleted file mode 100644 index 59f3442c05..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/dfc1c3a2e3ccdaf6f88c515fd00e8ad08421e431-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/e1dcc4e7ead6dfd1139ece7bf57d776cb9dac72d-7 b/tests/fuzzers/txfetcher/corpus/e1dcc4e7ead6dfd1139ece7bf57d776cb9dac72d-7 deleted file mode 100644 index 5ba489f99d..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/e1dcc4e7ead6dfd1139ece7bf57d776cb9dac72d-7 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/e39c2de2c8937d2cbd4339b13d6a0ce94d94f8d2-8 b/tests/fuzzers/txfetcher/corpus/e39c2de2c8937d2cbd4339b13d6a0ce94d94f8d2-8 deleted file mode 100644 index 0e9508938e..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/e39c2de2c8937d2cbd4339b13d6a0ce94d94f8d2-8 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/e72f76b9579c792e545d02fe405d9186f0d6c39b-6 b/tests/fuzzers/txfetcher/corpus/e72f76b9579c792e545d02fe405d9186f0d6c39b-6 deleted file mode 100644 index c4d34b1732..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/e72f76b9579c792e545d02fe405d9186f0d6c39b-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/eb70814d6355a4498b8f301ba8dbc34f895a9947-5 b/tests/fuzzers/txfetcher/corpus/eb70814d6355a4498b8f301ba8dbc34f895a9947-5 deleted file mode 100644 index bd57a22fb1..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/eb70814d6355a4498b8f301ba8dbc34f895a9947-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/ebdc17efe343e412634dca57cecd5a0e1ce1c1c7-5 b/tests/fuzzers/txfetcher/corpus/ebdc17efe343e412634dca57cecd5a0e1ce1c1c7-5 deleted file mode 100644 index aaa3f695ab..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/ebdc17efe343e412634dca57cecd5a0e1ce1c1c7-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/ec0a25eba8966b8f628d821b3cfbdf2dfd4bbb4c-3 b/tests/fuzzers/txfetcher/corpus/ec0a25eba8966b8f628d821b3cfbdf2dfd4bbb4c-3 deleted file mode 100644 index 65cf0df801..0000000000 --- a/tests/fuzzers/txfetcher/corpus/ec0a25eba8966b8f628d821b3cfbdf2dfd4bbb4c-3 +++ /dev/null @@ -1,13 +0,0 @@ -&^oȗ-----BEGIN RSA TESTING KEY----- -MIICXgIBAAKBgQDuLnQAI3mDgey3VBzWnB2L39JUU4txjeVE6myuDqkM/uGlfjb9 -SjY1bIw4iA5sBBZzHi3z0h1YV8PuxEbi4nW91IJm2gsvvZhIrHS3l6afab4pZB -l2+XsDulrKBxKKtD1rGxlG4Ljncdabn9vLZad2bSysqz/qTAUStvqJQIDAQAB -AoGAGRzwwir7XvBOAy5tM/uV6e+Zf6anZzus1s1K1ClbjbE6HXbnWWF/wbZGOpet -3Zm4vD6MXc7jpTLryzQIvVdfQbRc6+MUVeLKwZatTXtZru+Jk7hx0nTPy8Jcb -uJqFk541aEw+mMogY/xEcfbW6IOkp+4xqjlFLBEDytgbIECQQDvH/E6nk+hg4 -qzzVtxxr397vWrjrIgPbJpQvBsafG7b0dA4AFjwVbFLcj2pIMPQroozvjg1AkEA/v13/5M47K9vCxmb8QeD/aydfsgS5TeuNi8DoUBEmiSJwmaXY -fFUtxv7XvjwjN5B30pNEbc6Iuyt7y4MQJBAIt21su4bjeLKH8Q+ph2 -fQtuUE9txblTu14q3N7gHRZB4ZMhFYyDy8CKrN2cPg/Fvyt0Xlp/DoCzjA0CQQDU -y2ptGsuSmgUtWj3NM9xuwYPm+Z/F84K6+AYiZ6PYj013sovGKFYqVXVlxtIX -qyUBnu3X9s8ZfjZO7BAkl4R5Yl6cGhaJQYZHOe3JEMhVFaFf9Oes0UUothgiDktdQxdNLj7+5CWA== ------END RSASQ \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/eebe3b76aeba6deed965d17d2b024f7eae1a43f1-5 b/tests/fuzzers/txfetcher/corpus/eebe3b76aeba6deed965d17d2b024f7eae1a43f1-5 deleted file mode 100644 index 20d62e15b3..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/eebe3b76aeba6deed965d17d2b024f7eae1a43f1-5 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/ef8741a9faf030794d98ff113f556c68a24719a5-6 b/tests/fuzzers/txfetcher/corpus/ef8741a9faf030794d98ff113f556c68a24719a5-6 deleted file mode 100644 index 09fcd86d77..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/ef8741a9faf030794d98ff113f556c68a24719a5-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/efb7410d02418befeba25a43d676cc6124129125-4 b/tests/fuzzers/txfetcher/corpus/efb7410d02418befeba25a43d676cc6124129125-4 deleted file mode 100644 index 2191a7324a..0000000000 --- a/tests/fuzzers/txfetcher/corpus/efb7410d02418befeba25a43d676cc6124129125-4 +++ /dev/null @@ -1 +0,0 @@ -88242871'392752200424452601091531672177074144720616417147514758635765020556616 \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/f6f97d781a5a749903790e07db8619866cb7c3a1-6 b/tests/fuzzers/txfetcher/corpus/f6f97d781a5a749903790e07db8619866cb7c3a1-6 deleted file mode 100644 index 219a8d3682..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/f6f97d781a5a749903790e07db8619866cb7c3a1-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/f7a3cd00fa0e57742e7dbbb8283dcaea067eaf7b-5 b/tests/fuzzers/txfetcher/corpus/f7a3cd00fa0e57742e7dbbb8283dcaea067eaf7b-5 deleted file mode 100644 index f01ccd89ef..0000000000 --- a/tests/fuzzers/txfetcher/corpus/f7a3cd00fa0e57742e7dbbb8283dcaea067eaf7b-5 +++ /dev/null @@ -1,2 +0,0 @@ -Xyt0Xl/DoCzjA0CQQDU -y2ptGsuSmgUtWj3NM9xuwYPm+Z/F84K6+ARYi \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/f94d60a6c556ce485ab60088291760b8be25776c-6 b/tests/fuzzers/txfetcher/corpus/f94d60a6c556ce485ab60088291760b8be25776c-6 deleted file mode 100644 index 58d841ff03..0000000000 --- a/tests/fuzzers/txfetcher/corpus/f94d60a6c556ce485ab60088291760b8be25776c-6 +++ /dev/null @@ -1,2 +0,0 @@ -HZB4cQZde3JMNRcVFMO8dDFo -f9OeosiDdQQl \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/f9e627b2cb82ffa1ea5e0c6d7f2802f3000b18a8-6 b/tests/fuzzers/txfetcher/corpus/f9e627b2cb82ffa1ea5e0c6d7f2802f3000b18a8-6 deleted file mode 100644 index b5dfecc1e9..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/f9e627b2cb82ffa1ea5e0c6d7f2802f3000b18a8-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/corpus/fb3775aa24e5667e658920c05ba4b7b19ff256fb-5 b/tests/fuzzers/txfetcher/corpus/fb3775aa24e5667e658920c05ba4b7b19ff256fb-5 deleted file mode 100644 index 6f4927d822..0000000000 --- a/tests/fuzzers/txfetcher/corpus/fb3775aa24e5667e658920c05ba4b7b19ff256fb-5 +++ /dev/null @@ -1 +0,0 @@ -HZB4c2cPclieoverpGsumgUtWj3NMYPZ/F8t5YlNR8dDFoiDdQQl \ No newline at end of file diff --git a/tests/fuzzers/txfetcher/corpus/fd6386548e119a50db96b2fa406e54924c45a2d5-6 b/tests/fuzzers/txfetcher/corpus/fd6386548e119a50db96b2fa406e54924c45a2d5-6 deleted file mode 100644 index 6fff60edd4..0000000000 Binary files a/tests/fuzzers/txfetcher/corpus/fd6386548e119a50db96b2fa406e54924c45a2d5-6 and /dev/null differ diff --git a/tests/fuzzers/txfetcher/txfetcher_fuzzer.go b/tests/fuzzers/txfetcher/txfetcher_fuzzer.go deleted file mode 100644 index 48e58e955d..0000000000 --- a/tests/fuzzers/txfetcher/txfetcher_fuzzer.go +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2020 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package txfetcher - -import ( - "bytes" - "fmt" - "math/big" - "math/rand" - "time" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/common/mclock" - "github.com/dominant-strategies/go-quai/core/types" - "github.com/dominant-strategies/go-quai/eth/fetcher" -) - -var ( - peers []string - txs []*types.Transaction -) - -func init() { - // Random is nice, but we need it deterministic - rand := rand.New(rand.NewSource(0x3a29)) - - peers = make([]string, 10) - for i := 0; i < len(peers); i++ { - peers[i] = fmt.Sprintf("Peer #%d", i) - } - txs = make([]*types.Transaction, 65536) // We need to bump enough to hit all the limits - for i := 0; i < len(txs); i++ { - txs[i] = types.NewTransaction(rand.Uint64(), common.Address{byte(rand.Intn(256))}, new(big.Int), 0, new(big.Int), nil) - } -} - -func Fuzz(input []byte) int { - // Don't generate insanely large test cases, not much value in them - if len(input) > 16*1024 { - return 0 - } - verbose := false - r := bytes.NewReader(input) - - // Reduce the problem space for certain fuzz runs. Small tx space is better - // for testing clashes and in general the fetcher, but we should still run - // some tests with large spaces to hit potential issues on limits. - limit, err := r.ReadByte() - if err != nil { - return 0 - } - switch limit % 4 { - case 0: - txs = txs[:4] - case 1: - txs = txs[:256] - case 2: - txs = txs[:4096] - case 3: - // Full run - } - // Create a fetcher and hook into it's simulated fields - clock := new(mclock.Simulated) - rand := rand.New(rand.NewSource(0x3a29)) // Same used in package tests!!! - - f := fetcher.NewTxFetcherForTests( - func(common.Hash) bool { return false }, - func(txs []*types.Transaction) []error { - return make([]error, len(txs)) - }, - func(string, []common.Hash) error { return nil }, - clock, rand, - ) - f.Start() - defer f.Stop() - - // Try to throw random junk at the fetcher - for { - // Read the next command and abort if we're done - cmd, err := r.ReadByte() - if err != nil { - return 0 - } - switch cmd % 4 { - case 0: - // Notify a new set of transactions: - // Byte 1: Peer index to announce with - // Byte 2: Number of hashes to announce - // Byte 3-4, 5-6, etc: Transaction indices (2 byte) to announce - peerIdx, err := r.ReadByte() - if err != nil { - return 0 - } - peer := peers[int(peerIdx)%len(peers)] - - announceCnt, err := r.ReadByte() - if err != nil { - return 0 - } - announce := int(announceCnt) % (2 * len(txs)) // No point in generating too many duplicates - - var ( - announceIdxs = make([]int, announce) - announces = make([]common.Hash, announce) - ) - for i := 0; i < len(announces); i++ { - annBuf := make([]byte, 2) - if n, err := r.Read(annBuf); err != nil || n != 2 { - return 0 - } - announceIdxs[i] = (int(annBuf[0])*256 + int(annBuf[1])) % len(txs) - announces[i] = txs[announceIdxs[i]].Hash() - } - if verbose { - fmt.Println("Notify", peer, announceIdxs) - } - if err := f.Notify(peer, announces); err != nil { - panic(err) - } - - case 1: - // Deliver a new set of transactions: - // Byte 1: Peer index to announce with - // Byte 2: Number of hashes to announce - // Byte 3-4, 5-6, etc: Transaction indices (2 byte) to announce - peerIdx, err := r.ReadByte() - if err != nil { - return 0 - } - peer := peers[int(peerIdx)%len(peers)] - - deliverCnt, err := r.ReadByte() - if err != nil { - return 0 - } - deliver := int(deliverCnt) % (2 * len(txs)) // No point in generating too many duplicates - - var ( - deliverIdxs = make([]int, deliver) - deliveries = make([]*types.Transaction, deliver) - ) - for i := 0; i < len(deliveries); i++ { - deliverBuf := make([]byte, 2) - if n, err := r.Read(deliverBuf); err != nil || n != 2 { - return 0 - } - deliverIdxs[i] = (int(deliverBuf[0])*256 + int(deliverBuf[1])) % len(txs) - deliveries[i] = txs[deliverIdxs[i]] - } - directFlag, err := r.ReadByte() - if err != nil { - return 0 - } - direct := (directFlag % 2) == 0 - if verbose { - fmt.Println("Enqueue", peer, deliverIdxs, direct) - } - if err := f.Enqueue(peer, deliveries, direct); err != nil { - panic(err) - } - - case 2: - // Drop a peer: - // Byte 1: Peer index to drop - peerIdx, err := r.ReadByte() - if err != nil { - return 0 - } - peer := peers[int(peerIdx)%len(peers)] - if verbose { - fmt.Println("Drop", peer) - } - if err := f.Drop(peer); err != nil { - panic(err) - } - - case 3: - // Move the simulated clock forward - // Byte 1: 100ms increment to move forward - tickCnt, err := r.ReadByte() - if err != nil { - return 0 - } - tick := time.Duration(tickCnt) * 100 * time.Millisecond - if verbose { - fmt.Println("Sleep", tick) - } - clock.Run(tick) - } - } -} diff --git a/tests/fuzzers/vflux/clientpool-fuzzer.go b/tests/fuzzers/vflux/clientpool-fuzzer.go deleted file mode 100644 index b654d3ea04..0000000000 --- a/tests/fuzzers/vflux/clientpool-fuzzer.go +++ /dev/null @@ -1,333 +0,0 @@ -// Copyright 2021 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package vflux - -import ( - "bytes" - "encoding/binary" - "io" - "math" - "math/big" - "time" - - "github.com/dominant-strategies/go-quai/common/mclock" - "github.com/dominant-strategies/go-quai/ethdb/memorydb" - "github.com/dominant-strategies/go-quai/log" - "github.com/dominant-strategies/go-quai/p2p/enode" - "github.com/dominant-strategies/go-quai/p2p/enr" - "github.com/dominant-strategies/go-quai/rlp" -) - -var ( - debugMode = false - doLog = func(msg string, ctx ...interface{}) { - if !debugMode { - return - } - log.Info(msg, ctx...) - } -) - -type fuzzer struct { - peers [256]*clientPeer - disconnectList []*clientPeer - input io.Reader - exhausted bool - activeCount, activeCap uint64 - maxCount, maxCap uint64 -} - -type clientPeer struct { - fuzzer *fuzzer - node *enode.Node - freeID string - timeout time.Duration - - balance vfs.ConnectedBalance - capacity uint64 -} - -func (p *clientPeer) Node() *enode.Node { - return p.node -} - -func (p *clientPeer) FreeClientId() string { - return p.freeID -} - -func (p *clientPeer) InactiveAllowance() time.Duration { - return p.timeout -} - -func (p *clientPeer) UpdateCapacity(newCap uint64, requested bool) { - origin, originTotal := p.capacity, p.fuzzer.activeCap - p.fuzzer.activeCap -= p.capacity - if p.capacity != 0 { - p.fuzzer.activeCount-- - } - p.capacity = newCap - p.fuzzer.activeCap += p.capacity - if p.capacity != 0 { - p.fuzzer.activeCount++ - } - doLog("Update capacity", "peer", p.node.ID(), "origin", origin, "cap", newCap, "origintotal", originTotal, "total", p.fuzzer.activeCap, "requested", requested) -} - -func (p *clientPeer) Disconnect() { - origin, originTotal := p.capacity, p.fuzzer.activeCap - p.fuzzer.disconnectList = append(p.fuzzer.disconnectList, p) - p.fuzzer.activeCap -= p.capacity - if p.capacity != 0 { - p.fuzzer.activeCount-- - } - p.capacity = 0 - p.balance = nil - doLog("Disconnect", "peer", p.node.ID(), "origin", origin, "origintotal", originTotal, "total", p.fuzzer.activeCap) -} - -func newFuzzer(input []byte) *fuzzer { - f := &fuzzer{ - input: bytes.NewReader(input), - } - for i := range f.peers { - f.peers[i] = &clientPeer{ - fuzzer: f, - node: enode.SignNull(new(enr.Record), enode.ID{byte(i)}), - freeID: string([]byte{byte(i)}), - timeout: f.randomDelay(), - } - } - return f -} - -func (f *fuzzer) read(size int) []byte { - out := make([]byte, size) - if _, err := f.input.Read(out); err != nil { - f.exhausted = true - } - return out -} - -func (f *fuzzer) randomByte() byte { - d := f.read(1) - return d[0] -} - -func (f *fuzzer) randomBool() bool { - d := f.read(1) - return d[0]&1 == 1 -} - -func (f *fuzzer) randomInt(max int) int { - if max == 0 { - return 0 - } - if max <= 256 { - return int(f.randomByte()) % max - } - var a uint16 - if err := binary.Read(f.input, binary.LittleEndian, &a); err != nil { - f.exhausted = true - } - return int(a % uint16(max)) -} - -func (f *fuzzer) randomTokenAmount(signed bool) int64 { - x := uint64(f.randomInt(65000)) - x = x * x * x * x - - if signed && (x&1) == 1 { - if x <= math.MaxInt64 { - return -int64(x) - } - return math.MinInt64 - } - if x <= math.MaxInt64 { - return int64(x) - } - return math.MaxInt64 -} - -func (f *fuzzer) randomDelay() time.Duration { - delay := f.randomByte() - if delay < 128 { - return time.Duration(delay) * time.Second - } - return 0 -} - -func (f *fuzzer) randomFactors() vfs.PriceFactors { - return vfs.PriceFactors{ - TimeFactor: float64(f.randomByte()) / 25500, - CapacityFactor: float64(f.randomByte()) / 255, - RequestFactor: float64(f.randomByte()) / 255, - } -} - -func (f *fuzzer) connectedBalanceOp(balance vfs.ConnectedBalance, id enode.ID) { - switch f.randomInt(3) { - case 0: - cost := uint64(f.randomTokenAmount(false)) - balance.RequestServed(cost) - doLog("Serve request cost", "id", id, "amount", cost) - case 1: - posFactor, negFactor := f.randomFactors(), f.randomFactors() - balance.SetPriceFactors(posFactor, negFactor) - doLog("Set price factor", "pos", posFactor, "neg", negFactor) - case 2: - balance.GetBalance() - balance.GetRawBalance() - balance.GetPriceFactors() - } -} - -func (f *fuzzer) atomicBalanceOp(balance vfs.AtomicBalanceOperator, id enode.ID) { - switch f.randomInt(3) { - case 0: - amount := f.randomTokenAmount(true) - balance.AddBalance(amount) - doLog("Add balance", "id", id, "amount", amount) - case 1: - pos, neg := uint64(f.randomTokenAmount(false)), uint64(f.randomTokenAmount(false)) - balance.SetBalance(pos, neg) - doLog("Set balance", "id", id, "pos", pos, "neg", neg) - case 2: - balance.GetBalance() - balance.GetRawBalance() - balance.GetPriceFactors() - } -} - -func FuzzClientPool(input []byte) int { - if len(input) > 10000 { - return -1 - } - f := newFuzzer(input) - if f.exhausted { - return 0 - } - clock := &mclock.Simulated{} - db := memorydb.New() - pool := vfs.NewClientPool(db, 10, f.randomDelay(), clock, func() bool { return true }) - pool.Start() - defer pool.Stop() - - count := 0 - for !f.exhausted && count < 1000 { - count++ - switch f.randomInt(11) { - case 0: - i := int(f.randomByte()) - f.peers[i].balance = pool.Register(f.peers[i]) - doLog("Register peer", "id", f.peers[i].node.ID()) - case 1: - i := int(f.randomByte()) - f.peers[i].Disconnect() - doLog("Disconnect peer", "id", f.peers[i].node.ID()) - case 2: - f.maxCount = uint64(f.randomByte()) - f.maxCap = uint64(f.randomByte()) - f.maxCap *= f.maxCap - - count, cap := pool.Limits() - pool.SetLimits(f.maxCount, f.maxCap) - doLog("Set limits", "maxcount", f.maxCount, "maxcap", f.maxCap, "origincount", count, "oricap", cap) - case 3: - bias := f.randomDelay() - pool.SetConnectedBias(f.randomDelay()) - doLog("Set connection bias", "bias", bias) - case 4: - pos, neg := f.randomFactors(), f.randomFactors() - pool.SetDefaultFactors(pos, neg) - doLog("Set default factors", "pos", pos, "neg", neg) - case 5: - pos, neg := uint64(f.randomInt(50000)), uint64(f.randomInt(50000)) - pool.SetExpirationTCs(pos, neg) - doLog("Set expiration constants", "pos", pos, "neg", neg) - case 6: - var ( - index = f.randomByte() - reqCap = uint64(f.randomByte()) - bias = f.randomDelay() - requested = f.randomBool() - ) - if _, err := pool.SetCapacity(f.peers[index].node, reqCap, bias, requested); err == vfs.ErrCantFindMaximum { - panic(nil) - } - doLog("Set capacity", "id", f.peers[index].node.ID(), "reqcap", reqCap, "bias", bias, "requested", requested) - case 7: - index := f.randomByte() - if balance := f.peers[index].balance; balance != nil { - f.connectedBalanceOp(balance, f.peers[index].node.ID()) - } - case 8: - index := f.randomByte() - pool.BalanceOperation(f.peers[index].node.ID(), f.peers[index].freeID, func(balance vfs.AtomicBalanceOperator) { - count := f.randomInt(4) - for i := 0; i < count; i++ { - f.atomicBalanceOp(balance, f.peers[index].node.ID()) - } - }) - case 9: - pool.TotalTokenAmount() - pool.GetExpirationTCs() - pool.Active() - pool.Limits() - pool.GetPosBalanceIDs(f.peers[f.randomByte()].node.ID(), f.peers[f.randomByte()].node.ID(), f.randomInt(100)) - case 10: - req := vflux.CapacityQueryReq{ - Bias: uint64(f.randomByte()), - AddTokens: make([]vflux.IntOrInf, f.randomInt(vflux.CapacityQueryMaxLen+1)), - } - for i := range req.AddTokens { - v := vflux.IntOrInf{Type: uint8(f.randomInt(4))} - if v.Type < 2 { - v.Value = *big.NewInt(f.randomTokenAmount(false)) - } - req.AddTokens[i] = v - } - reqEnc, err := rlp.EncodeToBytes(&req) - if err != nil { - panic(err) - } - p := int(f.randomByte()) - if p < len(reqEnc) { - reqEnc[p] = f.randomByte() - } - pool.Handle(f.peers[f.randomByte()].node.ID(), f.peers[f.randomByte()].freeID, vflux.CapacityQueryName, reqEnc) - } - - for _, peer := range f.disconnectList { - pool.Unregister(peer) - doLog("Unregister peer", "id", peer.node.ID()) - } - f.disconnectList = nil - if d := f.randomDelay(); d > 0 { - clock.Run(d) - } - doLog("Clientpool stats in fuzzer", "count", f.activeCap, "maxcount", f.maxCount, "cap", f.activeCap, "maxcap", f.maxCap) - activeCount, activeCap := pool.Active() - doLog("Clientpool stats in pool", "count", activeCount, "cap", activeCap) - if activeCount != f.activeCount || activeCap != f.activeCap { - panic(nil) - } - if f.activeCount > f.maxCount || f.activeCap > f.maxCap { - panic(nil) - } - } - return 0 -} diff --git a/tests/fuzzers/vflux/debug/main.go b/tests/fuzzers/vflux/debug/main.go deleted file mode 100644 index db3b80ced9..0000000000 --- a/tests/fuzzers/vflux/debug/main.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2020 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package main - -import ( - "fmt" - "io/ioutil" - "os" - - "github.com/dominant-strategies/go-quai/log" - "github.com/dominant-strategies/go-quai/tests/fuzzers/vflux" -) - -func main() { - log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) - - if len(os.Args) != 2 { - fmt.Fprintf(os.Stderr, "Usage: debug \n") - fmt.Fprintf(os.Stderr, "Example\n") - fmt.Fprintf(os.Stderr, " $ debug ../crashers/4bbef6857c733a87ecf6fd8b9e7238f65eb9862a\n") - os.Exit(1) - } - crasher := os.Args[1] - data, err := ioutil.ReadFile(crasher) - if err != nil { - fmt.Fprintf(os.Stderr, "error loading crasher %v: %v", crasher, err) - os.Exit(1) - } - vflux.FuzzClientPool(data) -} diff --git a/tests/gen_btheader.go b/tests/gen_btheader.go deleted file mode 100644 index 85bfa32cc0..0000000000 --- a/tests/gen_btheader.go +++ /dev/null @@ -1,136 +0,0 @@ -// Code generated by github.com/fjl/gencodec. DO NOT EDIT. - -package tests - -import ( - "encoding/json" - "math/big" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/common/hexutil" - "github.com/dominant-strategies/go-quai/common/math" - "github.com/dominant-strategies/go-quai/core/types" -) - -var _ = (*btHeaderMarshaling)(nil) - -// MarshalJSON marshals as JSON. -func (b btHeader) MarshalJSON() ([]byte, error) { - type btHeader struct { - Bloom types.Bloom - Coinbase common.Address - MixHash common.Hash - Nonce types.BlockNonce - Number *math.HexOrDecimal256 - Hash common.Hash - ParentHash common.Hash - ReceiptTrie common.Hash - StateRoot common.Hash - TransactionsTrie common.Hash - UncleHash common.Hash - ExtraData hexutil.Bytes - Difficulty *math.HexOrDecimal256 - GasLimit math.HexOrDecimal64 - GasUsed math.HexOrDecimal64 - Timestamp math.HexOrDecimal64 - BaseFeePerGas *math.HexOrDecimal256 - } - var enc btHeader - enc.Bloom() = b.Bloom - enc.Coinbase() = b.Coinbase - enc.MixHash = b.MixHash - enc.Nonce() = b.Nonce - enc.Number() = (*math.HexOrDecimal256)(b.Number()) - enc.Hash = b.Hash - enc.ParentHash() = b.ParentHash - enc.ReceiptTrie = b.ReceiptTrie - enc.StateRoot = b.StateRoot - enc.TransactionsTrie = b.TransactionsTrie - enc.UncleHash() = b.UncleHash - enc.ExtraData = b.ExtraData - enc.Difficulty() = (*math.HexOrDecimal256)(b.Difficulty()) - enc.GasLimit() = math.HexOrDecimal64(b.GasLimit()) - enc.GasUsed() = math.HexOrDecimal64(b.GasUsed()) - enc.Timestamp = math.HexOrDecimal64(b.Timestamp) - enc.BaseFeePerGas = (*math.HexOrDecimal256)(b.BaseFeePerGas) - return json.Marshal(&enc) -} - -// UnmarshalJSON unmarshals from JSON. -func (b *btHeader) UnmarshalJSON(input []byte) error { - type btHeader struct { - Bloom *types.Bloom - Coinbase *common.Address - MixHash *common.Hash - Nonce *types.BlockNonce - Number *math.HexOrDecimal256 - Hash *common.Hash - ParentHash *common.Hash - ReceiptTrie *common.Hash - StateRoot *common.Hash - TransactionsTrie *common.Hash - UncleHash *common.Hash - ExtraData *hexutil.Bytes - Difficulty *math.HexOrDecimal256 - GasLimit *math.HexOrDecimal64 - GasUsed *math.HexOrDecimal64 - Timestamp *math.HexOrDecimal64 - BaseFeePerGas *math.HexOrDecimal256 - } - var dec btHeader - if err := json.Unmarshal(input, &dec); err != nil { - return err - } - if dec.Bloom() != nil { - b.Bloom() = *dec.Bloom - } - if dec.Coinbase() != nil { - b.Coinbase() = *dec.Coinbase - } - if dec.MixHash != nil { - b.MixHash = *dec.MixHash - } - if dec.Nonce() != nil { - b.Nonce() = *dec.Nonce - } - if dec.Number() != nil { - b.Number() = (*big.Int)(dec.Number()) - } - if dec.Hash != nil { - b.Hash = *dec.Hash - } - if dec.ParentHash() != nil { - b.ParentHash() = *dec.ParentHash - } - if dec.ReceiptTrie != nil { - b.ReceiptTrie = *dec.ReceiptTrie - } - if dec.StateRoot != nil { - b.StateRoot = *dec.StateRoot - } - if dec.TransactionsTrie != nil { - b.TransactionsTrie = *dec.TransactionsTrie - } - if dec.UncleHash() != nil { - b.UncleHash() = *dec.UncleHash - } - if dec.ExtraData != nil { - b.ExtraData = *dec.ExtraData - } - if dec.Difficulty() != nil { - b.Difficulty() = (*big.Int)(dec.Difficulty()) - } - if dec.GasLimit() != nil { - b.GasLimit() = uint64(*dec.GasLimit()) - } - if dec.GasUsed() != nil { - b.GasUsed() = uint64(*dec.GasUsed()) - } - if dec.Timestamp != nil { - b.Timestamp = uint64(*dec.Timestamp) - } - if dec.BaseFeePerGas != nil { - b.BaseFeePerGas = (*big.Int)(dec.BaseFeePerGas) - } - return nil -} diff --git a/tests/gen_difficultytest.go b/tests/gen_difficultytest.go deleted file mode 100644 index 8e9a16f646..0000000000 --- a/tests/gen_difficultytest.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by github.com/fjl/gencodec. DO NOT EDIT. - -package tests - -import ( - "encoding/json" - "math/big" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/common/math" -) - -var _ = (*difficultyTestMarshaling)(nil) - -// MarshalJSON marshals as JSON. -func (d DifficultyTest) MarshalJSON() ([]byte, error) { - type DifficultyTest struct { - ParentTimestamp math.HexOrDecimal64 `json:"parentTimestamp"` - ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"` - UncleHash common.Hash `json:"parentUncles"` - CurrentTimestamp math.HexOrDecimal64 `json:"currentTimestamp"` - CurrentBlockNumber math.HexOrDecimal64 `json:"currentBlockNumber"` - CurrentDifficulty *math.HexOrDecimal256 `json:"currentDifficulty"` - } - var enc DifficultyTest - enc.ParentTimestamp = math.HexOrDecimal64(d.ParentTimestamp) - enc.ParentDifficulty = (*math.HexOrDecimal256)(d.ParentDifficulty) - enc.UncleHash() = d.UncleHash - enc.CurrentTimestamp = math.HexOrDecimal64(d.CurrentTimestamp) - enc.CurrentBlockNumber = math.HexOrDecimal64(d.CurrentBlockNumber) - enc.CurrentDifficulty = (*math.HexOrDecimal256)(d.CurrentDifficulty) - return json.Marshal(&enc) -} - -// UnmarshalJSON unmarshals from JSON. -func (d *DifficultyTest) UnmarshalJSON(input []byte) error { - type DifficultyTest struct { - ParentTimestamp *math.HexOrDecimal64 `json:"parentTimestamp"` - ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"` - UncleHash *common.Hash `json:"parentUncles"` - CurrentTimestamp *math.HexOrDecimal64 `json:"currentTimestamp"` - CurrentBlockNumber *math.HexOrDecimal64 `json:"currentBlockNumber"` - CurrentDifficulty *math.HexOrDecimal256 `json:"currentDifficulty"` - } - var dec DifficultyTest - if err := json.Unmarshal(input, &dec); err != nil { - return err - } - if dec.ParentTimestamp != nil { - d.ParentTimestamp = uint64(*dec.ParentTimestamp) - } - if dec.ParentDifficulty != nil { - d.ParentDifficulty = (*big.Int)(dec.ParentDifficulty) - } - if dec.UncleHash() != nil { - d.UncleHash() = *dec.UncleHash - } - if dec.CurrentTimestamp != nil { - d.CurrentTimestamp = uint64(*dec.CurrentTimestamp) - } - if dec.CurrentBlockNumber != nil { - d.CurrentBlockNumber = uint64(*dec.CurrentBlockNumber) - } - if dec.CurrentDifficulty != nil { - d.CurrentDifficulty = (*big.Int)(dec.CurrentDifficulty) - } - return nil -} diff --git a/tests/gen_stenv.go b/tests/gen_stenv.go deleted file mode 100644 index 613118e100..0000000000 --- a/tests/gen_stenv.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by github.com/fjl/gencodec. DO NOT EDIT. - -package tests - -import ( - "encoding/json" - "errors" - "math/big" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/common/math" -) - -var _ = (*stEnvMarshaling)(nil) - -// MarshalJSON marshals as JSON. -func (s stEnv) MarshalJSON() ([]byte, error) { - type stEnv struct { - Coinbase common.UnprefixedAddress `json:"currentCoinbase" gencodec:"required"` - Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"required"` - GasLimit math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"` - Number math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"` - Timestamp math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"` - BaseFee *math.HexOrDecimal256 `json:"currentBaseFee" gencodec:"optional"` - } - var enc stEnv - enc.Coinbase() = common.UnprefixedAddress(s.Coinbase()) - enc.Difficulty() = (*math.HexOrDecimal256)(s.Difficulty()) - enc.GasLimit() = math.HexOrDecimal64(s.GasLimit()) - enc.Number() = math.HexOrDecimal64(s.Number()) - enc.Timestamp = math.HexOrDecimal64(s.Timestamp) - enc.BaseFee() = (*math.HexOrDecimal256)(s.BaseFee()) - return json.Marshal(&enc) -} - -// UnmarshalJSON unmarshals from JSON. -func (s *stEnv) UnmarshalJSON(input []byte) error { - type stEnv struct { - Coinbase *common.UnprefixedAddress `json:"currentCoinbase" gencodec:"required"` - Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"required"` - GasLimit *math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"` - Number *math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"` - Timestamp *math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"` - BaseFee *math.HexOrDecimal256 `json:"currentBaseFee" gencodec:"optional"` - } - var dec stEnv - if err := json.Unmarshal(input, &dec); err != nil { - return err - } - if dec.Coinbase() == nil { - return errors.New("missing required field 'currentCoinbase' for stEnv") - } - s.Coinbase() = common.Address(*dec.Coinbase()) - if dec.Difficulty() == nil { - return errors.New("missing required field 'currentDifficulty' for stEnv") - } - s.Difficulty() = (*big.Int)(dec.Difficulty()) - if dec.GasLimit() == nil { - return errors.New("missing required field 'currentGasLimit' for stEnv") - } - s.GasLimit() = uint64(*dec.GasLimit()) - if dec.Number() == nil { - return errors.New("missing required field 'currentNumber' for stEnv") - } - s.Number() = uint64(*dec.Number()) - if dec.Timestamp == nil { - return errors.New("missing required field 'currentTimestamp' for stEnv") - } - s.Timestamp = uint64(*dec.Timestamp) - if dec.BaseFee() != nil { - s.BaseFee() = (*big.Int)(dec.BaseFee()) - } - return nil -} diff --git a/tests/gen_sttransaction.go b/tests/gen_sttransaction.go deleted file mode 100644 index 247a152a8b..0000000000 --- a/tests/gen_sttransaction.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by github.com/fjl/gencodec. DO NOT EDIT. - -package tests - -import ( - "encoding/json" - "math/big" - - "github.com/dominant-strategies/go-quai/common/hexutil" - "github.com/dominant-strategies/go-quai/common/math" - "github.com/dominant-strategies/go-quai/core/types" -) - -var _ = (*stTransactionMarshaling)(nil) - -// MarshalJSON marshals as JSON. -func (s stTransaction) MarshalJSON() ([]byte, error) { - type stTransaction struct { - GasPrice *math.HexOrDecimal256 `json:"gasPrice"` - MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"` - MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"` - Nonce math.HexOrDecimal64 `json:"nonce"` - To string `json:"to"` - Data []string `json:"data"` - AccessLists []*types.AccessList `json:"accessLists,omitempty"` - GasLimit []math.HexOrDecimal64 `json:"gasLimit"` - Value []string `json:"value"` - PrivateKey hexutil.Bytes `json:"secretKey"` - } - var enc stTransaction - enc.GasPrice = (*math.HexOrDecimal256)(s.GasPrice) - enc.MaxFeePerGas = (*math.HexOrDecimal256)(s.MaxFeePerGas) - enc.MaxPriorityFeePerGas = (*math.HexOrDecimal256)(s.MaxPriorityFeePerGas) - enc.Nonce() = math.HexOrDecimal64(s.Nonce()) - enc.To = s.To - enc.Data = s.Data - enc.AccessLists = s.AccessLists - if s.GasLimit() != nil { - enc.GasLimit() = make([]math.HexOrDecimal64, len(s.GasLimit())) - for k, v := range s.GasLimit() { - enc.GasLimit[k] = math.HexOrDecimal64(v) - } - } - enc.Value = s.Value - enc.PrivateKey = s.PrivateKey - return json.Marshal(&enc) -} - -// UnmarshalJSON unmarshals from JSON. -func (s *stTransaction) UnmarshalJSON(input []byte) error { - type stTransaction struct { - GasPrice *math.HexOrDecimal256 `json:"gasPrice"` - MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"` - MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"` - Nonce *math.HexOrDecimal64 `json:"nonce"` - To *string `json:"to"` - Data []string `json:"data"` - AccessLists []*types.AccessList `json:"accessLists,omitempty"` - GasLimit []math.HexOrDecimal64 `json:"gasLimit"` - Value []string `json:"value"` - PrivateKey *hexutil.Bytes `json:"secretKey"` - } - var dec stTransaction - if err := json.Unmarshal(input, &dec); err != nil { - return err - } - if dec.GasPrice != nil { - s.GasPrice = (*big.Int)(dec.GasPrice) - } - if dec.MaxFeePerGas != nil { - s.MaxFeePerGas = (*big.Int)(dec.MaxFeePerGas) - } - if dec.MaxPriorityFeePerGas != nil { - s.MaxPriorityFeePerGas = (*big.Int)(dec.MaxPriorityFeePerGas) - } - if dec.Nonce() != nil { - s.Nonce() = uint64(*dec.Nonce()) - } - if dec.To != nil { - s.To = *dec.To - } - if dec.Data != nil { - s.Data = dec.Data - } - if dec.AccessLists != nil { - s.AccessLists = dec.AccessLists - } - if dec.GasLimit() != nil { - s.GasLimit() = make([]uint64, len(dec.GasLimit())) - for k, v := range dec.GasLimit() { - s.GasLimit[k] = uint64(v) - } - } - if dec.Value != nil { - s.Value = dec.Value - } - if dec.PrivateKey != nil { - s.PrivateKey = *dec.PrivateKey - } - return nil -} diff --git a/tests/gen_vmexec.go b/tests/gen_vmexec.go deleted file mode 100644 index 3472fc001e..0000000000 --- a/tests/gen_vmexec.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by github.com/fjl/gencodec. DO NOT EDIT. - -package tests - -import ( - "encoding/json" - "errors" - "math/big" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/common/hexutil" - "github.com/dominant-strategies/go-quai/common/math" -) - -var _ = (*vmExecMarshaling)(nil) - -// MarshalJSON marshals as JSON. -func (v vmExec) MarshalJSON() ([]byte, error) { - type vmExec struct { - Address common.UnprefixedAddress `json:"address" gencodec:"required"` - Caller common.UnprefixedAddress `json:"caller" gencodec:"required"` - Origin common.UnprefixedAddress `json:"origin" gencodec:"required"` - Code hexutil.Bytes `json:"code" gencodec:"required"` - Data hexutil.Bytes `json:"data" gencodec:"required"` - Value *math.HexOrDecimal256 `json:"value" gencodec:"required"` - GasLimit math.HexOrDecimal64 `json:"gas" gencodec:"required"` - GasPrice *math.HexOrDecimal256 `json:"gasPrice" gencodec:"required"` - } - var enc vmExec - enc.Address = common.UnprefixedAddress(v.Address) - enc.Caller = common.UnprefixedAddress(v.Caller) - enc.Origin = common.UnprefixedAddress(v.Origin) - enc.Code = v.Code - enc.Data = v.Data - enc.Value = (*math.HexOrDecimal256)(v.Value) - enc.GasLimit() = math.HexOrDecimal64(v.GasLimit()) - enc.GasPrice = (*math.HexOrDecimal256)(v.GasPrice) - return json.Marshal(&enc) -} - -// UnmarshalJSON unmarshals from JSON. -func (v *vmExec) UnmarshalJSON(input []byte) error { - type vmExec struct { - Address *common.UnprefixedAddress `json:"address" gencodec:"required"` - Caller *common.UnprefixedAddress `json:"caller" gencodec:"required"` - Origin *common.UnprefixedAddress `json:"origin" gencodec:"required"` - Code *hexutil.Bytes `json:"code" gencodec:"required"` - Data *hexutil.Bytes `json:"data" gencodec:"required"` - Value *math.HexOrDecimal256 `json:"value" gencodec:"required"` - GasLimit *math.HexOrDecimal64 `json:"gas" gencodec:"required"` - GasPrice *math.HexOrDecimal256 `json:"gasPrice" gencodec:"required"` - } - var dec vmExec - if err := json.Unmarshal(input, &dec); err != nil { - return err - } - if dec.Address == nil { - return errors.New("missing required field 'address' for vmExec") - } - v.Address = common.Address(*dec.Address) - if dec.Caller == nil { - return errors.New("missing required field 'caller' for vmExec") - } - v.Caller = common.Address(*dec.Caller) - if dec.Origin == nil { - return errors.New("missing required field 'origin' for vmExec") - } - v.Origin = common.Address(*dec.Origin) - if dec.Code == nil { - return errors.New("missing required field 'code' for vmExec") - } - v.Code = *dec.Code - if dec.Data == nil { - return errors.New("missing required field 'data' for vmExec") - } - v.Data = *dec.Data - if dec.Value == nil { - return errors.New("missing required field 'value' for vmExec") - } - v.Value = (*big.Int)(dec.Value) - if dec.GasLimit() == nil { - return errors.New("missing required field 'gas' for vmExec") - } - v.GasLimit() = uint64(*dec.GasLimit()) - if dec.GasPrice == nil { - return errors.New("missing required field 'gasPrice' for vmExec") - } - v.GasPrice = (*big.Int)(dec.GasPrice) - return nil -} diff --git a/tests/init.go b/tests/init.go deleted file mode 100644 index e682c4c3f9..0000000000 --- a/tests/init.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "fmt" - "sort" - - "github.com/dominant-strategies/go-quai/params" -) - -// Forks table defines supported forks and their chain config. -var Forks = map[string]*params.ChainConfig{} - -// Returns the set of defined fork names -func AvailableForks() []string { - var availableForks []string - for k := range Forks { - availableForks = append(availableForks, k) - } - sort.Strings(availableForks) - return availableForks -} - -// UnsupportedForkError is returned when a test requests a fork that isn't implemented. -type UnsupportedForkError struct { - Name string -} - -func (e UnsupportedForkError) Error() string { - return fmt.Sprintf("unsupported fork %q", e.Name) -} diff --git a/tests/init_test.go b/tests/init_test.go deleted file mode 100644 index 299affd13d..0000000000 --- a/tests/init_test.go +++ /dev/null @@ -1,287 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "encoding/json" - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "reflect" - "regexp" - "runtime" - "sort" - "strings" - "testing" - - "github.com/dominant-strategies/go-quai/params" -) - -var ( - baseDir = filepath.Join(".", "testdata") - blockTestDir = filepath.Join(baseDir, "BlockchainTests") - stateTestDir = filepath.Join(baseDir, "GeneralStateTests") - transactionTestDir = filepath.Join(baseDir, "TransactionTests") - vmTestDir = filepath.Join(baseDir, "VMTests") - rlpTestDir = filepath.Join(baseDir, "RLPTests") - difficultyTestDir = filepath.Join(baseDir, "BasicTests") -) - -func readJSON(reader io.Reader, value interface{}) error { - data, err := ioutil.ReadAll(reader) - if err != nil { - return fmt.Errorf("error reading JSON file: %v", err) - } - if err = json.Unmarshal(data, &value); err != nil { - if syntaxerr, ok := err.(*json.SyntaxError); ok { - line := findLine(data, syntaxerr.Offset) - return fmt.Errorf("JSON syntax error at line %v: %v", line, err) - } - return err - } - return nil -} - -func readJSONFile(fn string, value interface{}) error { - file, err := os.Open(fn) - if err != nil { - return err - } - defer file.Close() - - err = readJSON(file, value) - if err != nil { - return fmt.Errorf("%s in file %s", err.Error(), fn) - } - return nil -} - -// findLine returns the line number for the given offset into data. -func findLine(data []byte, offset int64) (line int) { - line = 1 - for i, r := range string(data) { - if int64(i) >= offset { - return - } - if r == '\n' { - line++ - } - } - return -} - -// testMatcher controls skipping and chain config assignment to tests. -type testMatcher struct { - configpat []testConfig - failpat []testFailure - skiploadpat []*regexp.Regexp - slowpat []*regexp.Regexp - runonlylistpat *regexp.Regexp -} - -type testConfig struct { - p *regexp.Regexp - config params.ChainConfig -} - -type testFailure struct { - p *regexp.Regexp - reason string -} - -// skipShortMode skips tests matching when the -short flag is used. -func (tm *testMatcher) slow(pattern string) { - tm.slowpat = append(tm.slowpat, regexp.MustCompile(pattern)) -} - -// skipLoad skips JSON loading of tests matching the pattern. -func (tm *testMatcher) skipLoad(pattern string) { - tm.skiploadpat = append(tm.skiploadpat, regexp.MustCompile(pattern)) -} - -// fails adds an expected failure for tests matching the pattern. -func (tm *testMatcher) fails(pattern string, reason string) { - if reason == "" { - panic("empty fail reason") - } - tm.failpat = append(tm.failpat, testFailure{regexp.MustCompile(pattern), reason}) -} - -func (tm *testMatcher) runonly(pattern string) { - tm.runonlylistpat = regexp.MustCompile(pattern) -} - -// config defines chain config for tests matching the pattern. -func (tm *testMatcher) config(pattern string, cfg params.ChainConfig) { - tm.configpat = append(tm.configpat, testConfig{regexp.MustCompile(pattern), cfg}) -} - -// findSkip matches name against test skip patterns. -func (tm *testMatcher) findSkip(name string) (reason string, skipload bool) { - isWin32 := runtime.GOARCH == "386" && runtime.GOOS == "windows" - for _, re := range tm.slowpat { - if re.MatchString(name) { - if testing.Short() { - return "skipped in -short mode", false - } - if isWin32 { - return "skipped on 32bit windows", false - } - } - } - for _, re := range tm.skiploadpat { - if re.MatchString(name) { - return "skipped by skipLoad", true - } - } - return "", false -} - -// findConfig returns the chain config matching defined patterns. -func (tm *testMatcher) findConfig(t *testing.T) *params.ChainConfig { - for _, m := range tm.configpat { - if m.p.MatchString(t.Name()) { - return &m.config - } - } - return new(params.ChainConfig) -} - -// checkFailure checks whether a failure is expected. -func (tm *testMatcher) checkFailure(t *testing.T, err error) error { - failReason := "" - for _, m := range tm.failpat { - if m.p.MatchString(t.Name()) { - failReason = m.reason - break - } - } - if failReason != "" { - t.Logf("expected failure: %s", failReason) - if err != nil { - t.Logf("error: %v", err) - return nil - } - return fmt.Errorf("test succeeded unexpectedly") - } - return err -} - -// walk invokes its runTest argument for all subtests in the given directory. -// -// runTest should be a function of type func(t *testing.T, name string, x ), -// where TestType is the type of the test contained in test files. -func (tm *testMatcher) walk(t *testing.T, dir string, runTest interface{}) { - // Walk the directory. - dirinfo, err := os.Stat(dir) - if os.IsNotExist(err) || !dirinfo.IsDir() { - fmt.Fprintf(os.Stderr, "can't find test files in %s, did you clone the tests submodule?\n", dir) - t.Skip("missing test files") - } - err = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { - name := filepath.ToSlash(strings.TrimPrefix(path, dir+string(filepath.Separator))) - if info.IsDir() { - if _, skipload := tm.findSkip(name + "/"); skipload { - return filepath.SkipDir - } - return nil - } - if filepath.Ext(path) == ".json" { - t.Run(name, func(t *testing.T) { tm.runTestFile(t, path, name, runTest) }) - } - return nil - }) - if err != nil { - t.Fatal(err) - } -} - -func (tm *testMatcher) runTestFile(t *testing.T, path, name string, runTest interface{}) { - if r, _ := tm.findSkip(name); r != "" { - t.Skip(r) - } - if tm.runonlylistpat != nil { - if !tm.runonlylistpat.MatchString(name) { - t.Skip("Skipped by runonly") - } - } - t.Parallel() - - // Load the file as map[string]. - m := makeMapFromTestFunc(runTest) - if err := readJSONFile(path, m.Addr().Interface()); err != nil { - t.Fatal(err) - } - - // Run all tests from the map. Don't wrap in a subtest if there is only one test in the file. - keys := sortedMapKeys(m) - if len(keys) == 1 { - runTestFunc(runTest, t, name, m, keys[0]) - } else { - for _, key := range keys { - name := name + "/" + key - t.Run(key, func(t *testing.T) { - if r, _ := tm.findSkip(name); r != "" { - t.Skip(r) - } - runTestFunc(runTest, t, name, m, key) - }) - } - } -} - -func makeMapFromTestFunc(f interface{}) reflect.Value { - stringT := reflect.TypeOf("") - testingT := reflect.TypeOf((*testing.T)(nil)) - ftyp := reflect.TypeOf(f) - if ftyp.Kind() != reflect.Func || ftyp.NumIn() != 3 || ftyp.NumOut() != 0 || ftyp.In(0) != testingT || ftyp.In(1) != stringT { - panic(fmt.Sprintf("bad test function type: want func(*testing.T, string, ), have %s", ftyp)) - } - testType := ftyp.In(2) - mp := reflect.New(reflect.MapOf(stringT, testType)) - return mp.Elem() -} - -func sortedMapKeys(m reflect.Value) []string { - keys := make([]string, m.Len()) - for i, k := range m.MapKeys() { - keys[i] = k.String() - } - sort.Strings(keys) - return keys -} - -func runTestFunc(runTest interface{}, t *testing.T, name string, m reflect.Value, key string) { - reflect.ValueOf(runTest).Call([]reflect.Value{ - reflect.ValueOf(t), - reflect.ValueOf(name), - m.MapIndex(reflect.ValueOf(key)), - }) -} - -func TestMatcherRunonlylist(t *testing.T) { - t.Parallel() - tm := new(testMatcher) - tm.runonly("invalid*") - tm.walk(t, rlpTestDir, func(t *testing.T, name string, test *RLPTest) { - if name[:len("invalidRLPTest.json")] != "invalidRLPTest.json" { - t.Fatalf("invalid test found: %s != invalidRLPTest.json", name) - } - }) -} diff --git a/tests/rlp_test.go b/tests/rlp_test.go deleted file mode 100644 index 79a1683eb2..0000000000 --- a/tests/rlp_test.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "testing" -) - -func TestRLP(t *testing.T) { - t.Parallel() - tm := new(testMatcher) - tm.walk(t, rlpTestDir, func(t *testing.T, name string, test *RLPTest) { - if err := tm.checkFailure(t, test.Run()); err != nil { - t.Error(err) - } - }) -} diff --git a/tests/rlp_test_util.go b/tests/rlp_test_util.go deleted file mode 100644 index 2f0287013f..0000000000 --- a/tests/rlp_test_util.go +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "bytes" - "encoding/hex" - "errors" - "fmt" - "math/big" - "strings" - - "github.com/dominant-strategies/go-quai/rlp" -) - -// RLPTest is the JSON structure of a single RLP test. -type RLPTest struct { - // If the value of In is "INVALID" or "VALID", the test - // checks whether Out can be decoded into a value of - // type interface{}. - // - // For other JSON values, In is treated as a driver for - // calls to rlp.Stream. The test also verifies that encoding - // In produces the bytes in Out. - In interface{} - - // Out is a hex-encoded RLP value. - Out string -} - -// FromHex returns the bytes represented by the hexadecimal string s. -// s may be prefixed with "0x". -// This is copy-pasted from bytes.go, which does not return the error -func FromHex(s string) ([]byte, error) { - if len(s) > 1 && (s[0:2] == "0x" || s[0:2] == "0X") { - s = s[2:] - } - if len(s)%2 == 1 { - s = "0" + s - } - return hex.DecodeString(s) -} - -// Run executes the test. -func (t *RLPTest) Run() error { - outb, err := FromHex(t.Out) - if err != nil { - return fmt.Errorf("invalid hex in Out") - } - - // Handle simple decoding tests with no actual In value. - if t.In == "VALID" || t.In == "INVALID" { - return checkDecodeInterface(outb, t.In == "VALID") - } - - // Check whether encoding the value produces the same bytes. - in := translateJSON(t.In) - b, err := rlp.EncodeToBytes(in) - if err != nil { - return fmt.Errorf("encode failed: %v", err) - } - if !bytes.Equal(b, outb) { - return fmt.Errorf("encode produced %x, want %x", b, outb) - } - // Test stream decoding. - s := rlp.NewStream(bytes.NewReader(outb), 0) - return checkDecodeFromJSON(s, in) -} - -func checkDecodeInterface(b []byte, isValid bool) error { - err := rlp.DecodeBytes(b, new(interface{})) - switch { - case isValid && err != nil: - return fmt.Errorf("decoding failed: %v", err) - case !isValid && err == nil: - return fmt.Errorf("decoding of invalid value succeeded") - } - return nil -} - -// translateJSON makes test json values encodable with RLP. -func translateJSON(v interface{}) interface{} { - switch v := v.(type) { - case float64: - return uint64(v) - case string: - if len(v) > 0 && v[0] == '#' { // # starts a faux big int. - big, ok := new(big.Int).SetString(v[1:], 10) - if !ok { - panic(fmt.Errorf("bad test: bad big int: %q", v)) - } - return big - } - return []byte(v) - case []interface{}: - new := make([]interface{}, len(v)) - for i := range v { - new[i] = translateJSON(v[i]) - } - return new - default: - panic(fmt.Errorf("can't handle %T", v)) - } -} - -// checkDecodeFromJSON decodes from s guided by exp. exp drives the -// Stream by invoking decoding operations (Uint, Big, List, ...) based -// on the type of each value. The value decoded from the RLP stream -// must match the JSON value. -func checkDecodeFromJSON(s *rlp.Stream, exp interface{}) error { - switch exp := exp.(type) { - case uint64: - i, err := s.Uint() - if err != nil { - return addStack("Uint", exp, err) - } - if i != exp { - return addStack("Uint", exp, fmt.Errorf("result mismatch: got %d", i)) - } - case *big.Int: - big := new(big.Int) - if err := s.Decode(&big); err != nil { - return addStack("Big", exp, err) - } - if big.Cmp(exp) != 0 { - return addStack("Big", exp, fmt.Errorf("result mismatch: got %d", big)) - } - case []byte: - b, err := s.Bytes() - if err != nil { - return addStack("Bytes", exp, err) - } - if !bytes.Equal(b, exp) { - return addStack("Bytes", exp, fmt.Errorf("result mismatch: got %x", b)) - } - case []interface{}: - if _, err := s.List(); err != nil { - return addStack("List", exp, err) - } - for i, v := range exp { - if err := checkDecodeFromJSON(s, v); err != nil { - return addStack(fmt.Sprintf("[%d]", i), exp, err) - } - } - if err := s.ListEnd(); err != nil { - return addStack("ListEnd", exp, err) - } - default: - panic(fmt.Errorf("unhandled type: %T", exp)) - } - return nil -} - -func addStack(op string, val interface{}, err error) error { - lines := strings.Split(err.Error(), "\n") - lines = append(lines, fmt.Sprintf("\t%s: %v", op, val)) - return errors.New(strings.Join(lines, "\n")) -} diff --git a/tests/solidity/bytecode.js b/tests/solidity/bytecode.js deleted file mode 100644 index 8796aabfa3..0000000000 --- a/tests/solidity/bytecode.js +++ /dev/null @@ -1,6 +0,0 @@ -{ - "linkReferences": {}, - "object": "608060405234801561001057600080fd5b5061001961007a565b604051809103906000f080158015610035573d6000803e3d6000fd5b506000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061008a565b60405161015f8061055c83390190565b6104c3806100996000396000f3fe60806040526004361061005c576000357c01000000000000000000000000000000000000000000000000000000009004806355313dea146100615780636d3d141614610078578063b9d1e5aa1461008f578063f8a8fd6d146100a6575b600080fd5b34801561006d57600080fd5b506100766100bd565b005b34801561008457600080fd5b5061008d6100bf565b005b34801561009b57600080fd5b506100a46100c4565b005b3480156100b257600080fd5b506100bb6100c6565b005b005b600080fd5bfe5b600160021a6002f35b60058110156100e3576001810190506100cf565b5060065b60058111156100fb576001810190506100e7565b5060015b6005811215610113576001810190506100ff565b5060065b600581131561012b57600181019050610117565b5060021561013857600051505b60405160208101602060048337505060405160208101602060048339505060405160208101602060048360003c50503660005b81811015610182576002815260018101905061016b565b505060008020506000602060403e6010608060106040610123612710fa506020610123600af05060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600060405180807f697353616d654164647265737328616464726573732c61646472657373290000815250601e01905060405180910390209050600033905060405182815281600482015281602482015260648101604052602081604483600088611388f1505060405182815281600482015281602482015260648101604052602081604483600088611388f250506040518281528160048201528160248201526064810160405260208160448387611388f4505060006242004290507f50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb206001026040518082815260200191505060405180910390a07f50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb206001027f50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb206001026040518082815260200191505060405180910390a13373ffffffffffffffffffffffffffffffffffffffff166001027f50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb206001027f50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb206001026040518082815260200191505060405180910390a2806001023373ffffffffffffffffffffffffffffffffffffffff166001027f50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb206001027f50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb206001026040518082815260200191505060405180910390a380600102816001023373ffffffffffffffffffffffffffffffffffffffff166001027f50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb206001027f50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb206001026040518082815260200191505060405180910390a46002fffea165627a7a723058200e51baa2b454b47fdf0ef596fa24aff8ed3a3727b7481ebd25349182ce7152a30029608060405234801561001057600080fd5b5061013f806100206000396000f3fe60806040526004361061003b576000357c010000000000000000000000000000000000000000000000000000000090048063161e715014610040575b600080fd5b34801561004c57600080fd5b506100af6004803603604081101561006357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506100c9565b604051808215151515815260200191505060405180910390f35b60008173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610108576001905061010d565b600090505b9291505056fea165627a7a72305820358f67a58c115ea636b0b8e5c4ca7a52b8192d0f3fa98a4434d6ea04596b5d0d0029", - "opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x19 PUSH2 0x7A JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 PUSH1 0x0 CREATE DUP1 ISZERO DUP1 ISZERO PUSH2 0x35 JUMPI RETURNDATASIZE PUSH1 0x0 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x0 REVERT JUMPDEST POP PUSH1 0x0 DUP1 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF MUL NOT AND SWAP1 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND MUL OR SWAP1 SSTORE POP PUSH2 0x8A JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0x15F DUP1 PUSH2 0x55C DUP4 CODECOPY ADD SWAP1 JUMP JUMPDEST PUSH2 0x4C3 DUP1 PUSH2 0x99 PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN INVALID PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH2 0x5C JUMPI PUSH1 0x0 CALLDATALOAD PUSH29 0x100000000000000000000000000000000000000000000000000000000 SWAP1 DIV DUP1 PUSH4 0x55313DEA EQ PUSH2 0x61 JUMPI DUP1 PUSH4 0x6D3D1416 EQ PUSH2 0x78 JUMPI DUP1 PUSH4 0xB9D1E5AA EQ PUSH2 0x8F JUMPI DUP1 PUSH4 0xF8A8FD6D EQ PUSH2 0xA6 JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x6D JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x76 PUSH2 0xBD JUMP JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x84 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x8D PUSH2 0xBF JUMP JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x9B JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xA4 PUSH2 0xC4 JUMP JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xB2 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xBB PUSH2 0xC6 JUMP JUMPDEST STOP JUMPDEST STOP JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST INVALID JUMPDEST PUSH1 0x1 PUSH1 0x2 BYTE PUSH1 0x2 RETURN JUMPDEST PUSH1 0x5 DUP2 LT ISZERO PUSH2 0xE3 JUMPI PUSH1 0x1 DUP2 ADD SWAP1 POP PUSH2 0xCF JUMP JUMPDEST POP PUSH1 0x6 JUMPDEST PUSH1 0x5 DUP2 GT ISZERO PUSH2 0xFB JUMPI PUSH1 0x1 DUP2 ADD SWAP1 POP PUSH2 0xE7 JUMP JUMPDEST POP PUSH1 0x1 JUMPDEST PUSH1 0x5 DUP2 SLT ISZERO PUSH2 0x113 JUMPI PUSH1 0x1 DUP2 ADD SWAP1 POP PUSH2 0xFF JUMP JUMPDEST POP PUSH1 0x6 JUMPDEST PUSH1 0x5 DUP2 SGT ISZERO PUSH2 0x12B JUMPI PUSH1 0x1 DUP2 ADD SWAP1 POP PUSH2 0x117 JUMP JUMPDEST POP PUSH1 0x2 ISZERO PUSH2 0x138 JUMPI PUSH1 0x0 MLOAD POP JUMPDEST PUSH1 0x40 MLOAD PUSH1 0x20 DUP2 ADD PUSH1 0x20 PUSH1 0x4 DUP4 CALLDATACOPY POP POP PUSH1 0x40 MLOAD PUSH1 0x20 DUP2 ADD PUSH1 0x20 PUSH1 0x4 DUP4 CODECOPY POP POP PUSH1 0x40 MLOAD PUSH1 0x20 DUP2 ADD PUSH1 0x20 PUSH1 0x4 DUP4 PUSH1 0x0 EXTCODECOPY POP POP CALLDATASIZE PUSH1 0x0 JUMPDEST DUP2 DUP2 LT ISZERO PUSH2 0x182 JUMPI PUSH1 0x2 DUP2 MSTORE PUSH1 0x1 DUP2 ADD SWAP1 POP PUSH2 0x16B JUMP JUMPDEST POP POP PUSH1 0x0 DUP1 KECCAK256 POP PUSH1 0x0 PUSH1 0x20 PUSH1 0x40 RETURNDATACOPY PUSH1 0x10 PUSH1 0x80 PUSH1 0x10 PUSH1 0x40 PUSH2 0x123 PUSH2 0x2710 STATICCALL POP PUSH1 0x20 PUSH2 0x123 PUSH1 0xA CREATE POP PUSH1 0x0 DUP1 PUSH1 0x0 SWAP1 SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND SWAP1 POP PUSH1 0x0 PUSH1 0x40 MLOAD DUP1 DUP1 PUSH32 0x697353616D654164647265737328616464726573732C61646472657373290000 DUP2 MSTORE POP PUSH1 0x1E ADD SWAP1 POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 KECCAK256 SWAP1 POP PUSH1 0x0 CALLER SWAP1 POP PUSH1 0x40 MLOAD DUP3 DUP2 MSTORE DUP2 PUSH1 0x4 DUP3 ADD MSTORE DUP2 PUSH1 0x24 DUP3 ADD MSTORE PUSH1 0x64 DUP2 ADD PUSH1 0x40 MSTORE PUSH1 0x20 DUP2 PUSH1 0x44 DUP4 PUSH1 0x0 DUP9 PUSH2 0x1388 CALL POP POP PUSH1 0x40 MLOAD DUP3 DUP2 MSTORE DUP2 PUSH1 0x4 DUP3 ADD MSTORE DUP2 PUSH1 0x24 DUP3 ADD MSTORE PUSH1 0x64 DUP2 ADD PUSH1 0x40 MSTORE PUSH1 0x20 DUP2 PUSH1 0x44 DUP4 PUSH1 0x0 DUP9 PUSH2 0x1388 CALLCODE POP POP PUSH1 0x40 MLOAD DUP3 DUP2 MSTORE DUP2 PUSH1 0x4 DUP3 ADD MSTORE DUP2 PUSH1 0x24 DUP3 ADD MSTORE PUSH1 0x64 DUP2 ADD PUSH1 0x40 MSTORE PUSH1 0x20 DUP2 PUSH1 0x44 DUP4 DUP8 PUSH2 0x1388 DELEGATECALL POP POP PUSH1 0x0 PUSH3 0x420042 SWAP1 POP PUSH32 0x50CB9FE53DAA9737B786AB3646F04D0150DC50EF4E75F59509D83667AD5ADB20 PUSH1 0x1 MUL PUSH1 0x40 MLOAD DUP1 DUP3 DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 LOG0 PUSH32 0x50CB9FE53DAA9737B786AB3646F04D0150DC50EF4E75F59509D83667AD5ADB20 PUSH1 0x1 MUL PUSH32 0x50CB9FE53DAA9737B786AB3646F04D0150DC50EF4E75F59509D83667AD5ADB20 PUSH1 0x1 MUL PUSH1 0x40 MLOAD DUP1 DUP3 DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 LOG1 CALLER PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH1 0x1 MUL PUSH32 0x50CB9FE53DAA9737B786AB3646F04D0150DC50EF4E75F59509D83667AD5ADB20 PUSH1 0x1 MUL PUSH32 0x50CB9FE53DAA9737B786AB3646F04D0150DC50EF4E75F59509D83667AD5ADB20 PUSH1 0x1 MUL PUSH1 0x40 MLOAD DUP1 DUP3 DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 LOG2 DUP1 PUSH1 0x1 MUL CALLER PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH1 0x1 MUL PUSH32 0x50CB9FE53DAA9737B786AB3646F04D0150DC50EF4E75F59509D83667AD5ADB20 PUSH1 0x1 MUL PUSH32 0x50CB9FE53DAA9737B786AB3646F04D0150DC50EF4E75F59509D83667AD5ADB20 PUSH1 0x1 MUL PUSH1 0x40 MLOAD DUP1 DUP3 DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 LOG3 DUP1 PUSH1 0x1 MUL DUP2 PUSH1 0x1 MUL CALLER PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH1 0x1 MUL PUSH32 0x50CB9FE53DAA9737B786AB3646F04D0150DC50EF4E75F59509D83667AD5ADB20 PUSH1 0x1 MUL PUSH32 0x50CB9FE53DAA9737B786AB3646F04D0150DC50EF4E75F59509D83667AD5ADB20 PUSH1 0x1 MUL PUSH1 0x40 MLOAD DUP1 DUP3 DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 LOG4 PUSH1 0x2 SELFDESTRUCT INVALID LOG1 PUSH6 0x627A7A723058 KECCAK256 0xe MLOAD 0xba LOG2 0xb4 SLOAD 0xb4 PUSH32 0xDF0EF596FA24AFF8ED3A3727B7481EBD25349182CE7152A30029608060405234 DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x13F DUP1 PUSH2 0x20 PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN INVALID PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH2 0x3B JUMPI PUSH1 0x0 CALLDATALOAD PUSH29 0x100000000000000000000000000000000000000000000000000000000 SWAP1 DIV DUP1 PUSH4 0x161E7150 EQ PUSH2 0x40 JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x4C JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xAF PUSH1 0x4 DUP1 CALLDATASIZE SUB PUSH1 0x40 DUP2 LT ISZERO PUSH2 0x63 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 ADD SWAP1 DUP1 DUP1 CALLDATALOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 DUP1 CALLDATALOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2 0xC9 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 DUP3 ISZERO ISZERO ISZERO ISZERO DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH1 0x0 DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND EQ ISZERO PUSH2 0x108 JUMPI PUSH1 0x1 SWAP1 POP PUSH2 0x10D JUMP JUMPDEST PUSH1 0x0 SWAP1 POP JUMPDEST SWAP3 SWAP2 POP POP JUMP INVALID LOG1 PUSH6 0x627A7A723058 KECCAK256 CALLDATALOAD DUP16 PUSH8 0xA58C115EA636B0B8 0xe5 0xc4 0xca PUSH27 0x52B8192D0F3FA98A4434D6EA04596B5D0D00290000000000000000 ", - "sourceMap": "221:8828:0:-;;;263:110;8:9:-1;5:2;;;30:1;27;20:12;5:2;263:110:0;324:11;;:::i;:::-;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;324:11:0;316:5;;:19;;;;;;;;;;;;;;;;;;221:8828;;;;;;;;;;;;:::o;:::-;;;;;;;" -} diff --git a/tests/solidity/contracts/Migrations.sol b/tests/solidity/contracts/Migrations.sol deleted file mode 100644 index c378ffb028..0000000000 --- a/tests/solidity/contracts/Migrations.sol +++ /dev/null @@ -1,23 +0,0 @@ -pragma solidity >=0.4.21 <0.6.0; - -contract Migrations { - address public owner; - uint public last_completed_migration; - - constructor() public { - owner = msg.sender; - } - - modifier restricted() { - if (msg.sender == owner) _; - } - - function setCompleted(uint completed) public restricted { - last_completed_migration = completed; - } - - function upgrade(address new_address) public restricted { - Migrations upgraded = Migrations(new_address); - upgraded.setCompleted(last_completed_migration); - } -} diff --git a/tests/solidity/contracts/OpCodes.sol b/tests/solidity/contracts/OpCodes.sol deleted file mode 100644 index 7d2f28557b..0000000000 --- a/tests/solidity/contracts/OpCodes.sol +++ /dev/null @@ -1,321 +0,0 @@ -pragma solidity >=0.4.21 <0.6.0; - -contract Test1 { - function isSameAddress(address a, address b) public returns(bool){ //Simply add the two arguments and return - if (a == b) return true; - return false; - } -} - -contract OpCodes { - - Test1 test1; - - constructor() public { //Constructor function - test1 = new Test1(); //Create new "Test1" function - } - - modifier onlyOwner(address _owner) { - require(msg.sender == _owner); - _; - } - // Add a todo to the list - function test() public { - - //simple_instructions - /*assembly { pop(sub(dup1, mul(dup1, dup1))) }*/ - - //keywords - assembly { pop(address) return(2, byte(2,1)) } - - //label_complex - /*assembly { 7 abc: 8 eq jump(abc) jumpi(eq(7, 8), abc) pop } - assembly { pop(jumpi(eq(7, 8), abc)) jump(abc) }*/ - - //functional - /*assembly { let x := 2 add(7, mul(6, x)) mul(7, 8) add =: x }*/ - - //for_statement - assembly { for { let i := 1 } lt(i, 5) { i := add(i, 1) } {} } - assembly { for { let i := 6 } gt(i, 5) { i := add(i, 1) } {} } - assembly { for { let i := 1 } slt(i, 5) { i := add(i, 1) } {} } - assembly { for { let i := 6 } sgt(i, 5) { i := add(i, 1) } {} } - - //no_opcodes_in_strict - assembly { pop(callvalue()) } - - //no_dup_swap_in_strict - /*assembly { swap1() }*/ - - //print_functional - assembly { let x := mul(sload(0x12), 7) } - - //print_if - assembly { if 2 { pop(mload(0)) }} - - //function_definitions_multiple_args - assembly { function f(a, d){ mstore(a, d) } function g(a, d) -> x, y {}} - - //sstore - assembly { function f(a, d){ sstore(a, d) } function g(a, d) -> x, y {}} - - //mstore8 - assembly { function f(a, d){ mstore8(a, d) } function g(a, d) -> x, y {}} - - //calldatacopy - assembly { - let a := mload(0x40) - let b := add(a, 32) - calldatacopy(a, 4, 32) - /*calldatacopy(b, add(4, 32), 32)*/ - /*result := add(mload(a), mload(b))*/ - } - - //codecopy - assembly { - let a := mload(0x40) - let b := add(a, 32) - codecopy(a, 4, 32) - } - - //codecopy - assembly { - let a := mload(0x40) - let b := add(a, 32) - extcodecopy(0, a, 4, 32) - } - - //for_statement - assembly { let x := calldatasize() for { let i := 0} lt(i, x) { i := add(i, 1) } { mstore(i, 2) } } - - //keccak256 - assembly { pop(keccak256(0,0)) } - - //returndatasize - assembly { let r := returndatasize } - - //returndatacopy - assembly { returndatacopy(64, 32, 0) } - //staticcall - assembly { pop(staticcall(10000, 0x123, 64, 0x10, 128, 0x10)) } - - /*//create2 - assembly { pop(create2(10, 0x123, 32, 64)) }*/ - - //create - assembly { pop(create(10, 0x123, 32)) } - - //shift - /*assembly { pop(shl(10, 32)) } - assembly { pop(shr(10, 32)) } - assembly { pop(sar(10, 32)) }*/ - - - //not - assembly { pop( not(0x1f)) } - - //exp - assembly { pop( exp(2, 226)) } - - //mod - assembly { pop( mod(3, 9)) } - - //smod - assembly { pop( smod(3, 9)) } - - //div - assembly { pop( div(4, 2)) } - - //sdiv - assembly { pop( sdiv(4, 2)) } - - //iszero - assembly { pop(iszero(1)) } - - //and - assembly { pop(and(2,3)) } - - //or - assembly { pop(or(3,3)) } - - //xor - assembly { pop(xor(3,3)) } - - //addmod - assembly { pop(addmod(3,3,6)) } - - //mulmod - assembly { pop(mulmod(3,3,3)) } - - //signextend - assembly { pop(signextend(1, 10)) } - - //sha3 - assembly { pop(calldataload(0)) } - - //blockhash - assembly { pop(blockhash(sub(number(), 1))) } - - //balance - assembly { pop(balance(0x0)) } - - //caller - assembly { pop(caller()) } - - //codesize - assembly { pop(codesize()) } - - //extcodesize - assembly { pop(extcodesize(0x1)) } - - //origin - assembly { pop(origin()) } - - //gas - assembly { pop(gas())} - - //msize - assembly { pop(msize())} - - //pc - assembly { pop(pc())} - - //gasprice - assembly { pop(gasprice())} - - //coinbase - assembly { pop(coinbase())} - - //timestamp - assembly { pop(timestamp())} - - //number - assembly { pop(number())} - - //difficulty - assembly { pop(difficulty())} - - //gaslimit - assembly { pop(gaslimit())} - - //call - address contractAddr = address(test1); - bytes4 sig = bytes4(keccak256("isSameAddress(address,address)")); //Function signature - address a = msg.sender; - - assembly { - let x := mload(0x40) //Find empty storage location using "free memory pointer" - mstore(x,sig) //Place signature at begining of empty storage - mstore(add(x,0x04),a) // first address parameter. just after signature - mstore(add(x,0x24),a) // 2nd address parameter - first padded. add 32 bytes (not 20 bytes) - mstore(0x40,add(x,0x64)) // this is missing in other examples. Set free pointer before function call. so it is used by called function. - // new free pointer position after the output values of the called function. - - let success := call( - 5000, //5k gas - contractAddr, //To addr - 0, //No wei passed - x, // Inputs are at location x - 0x44, //Inputs size two padded, so 68 bytes - x, //Store output over input - 0x20) //Output is 32 bytes long - } - - //callcode - assembly { - let x := mload(0x40) //Find empty storage location using "free memory pointer" - mstore(x,sig) //Place signature at begining of empty storage - mstore(add(x,0x04),a) // first address parameter. just after signature - mstore(add(x,0x24),a) // 2nd address parameter - first padded. add 32 bytes (not 20 bytes) - mstore(0x40,add(x,0x64)) // this is missing in other examples. Set free pointer before function call. so it is used by called function. - // new free pointer position after the output values of the called function. - - let success := callcode( - 5000, //5k gas - contractAddr, //To addr - 0, //No wei passed - x, // Inputs are at location x - 0x44, //Inputs size two padded, so 68 bytes - x, //Store output over input - 0x20) //Output is 32 bytes long - } - - //delegatecall - assembly { - let x := mload(0x40) //Find empty storage location using "free memory pointer" - mstore(x,sig) //Place signature at begining of empty storage - mstore(add(x,0x04),a) // first address parameter. just after signature - mstore(add(x,0x24),a) // 2nd address parameter - first padded. add 32 bytes (not 20 bytes) - mstore(0x40,add(x,0x64)) // this is missing in other examples. Set free pointer before function call. so it is used by called function. - // new free pointer position after the output values of the called function. - - let success := delegatecall( - 5000, //5k gas - contractAddr, //To addr - x, // Inputs are at location x - 0x44, //Inputs size two padded, so 68 bytes - x, //Store output over input - 0x20) //Output is 32 bytes long - } - - uint256 _id = 0x420042; - - //log0 - log0( - bytes32(0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20) - ); - - //log1 - log1( - bytes32(0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20), - bytes32(0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20) - ); - - //log2 - log2( - bytes32(0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20), - bytes32(0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20), - bytes32(uint256(msg.sender)) - ); - - //log3 - log3( - bytes32(0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20), - bytes32(0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20), - bytes32(uint256(msg.sender)), - bytes32(_id) - ); - - //log4 - log4( - bytes32(0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20), - bytes32(0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20), - bytes32(uint256(msg.sender)), - bytes32(_id), - bytes32(_id) - - ); - - //selfdestruct - assembly { selfdestruct(0x02) } - } - - function test_revert() public { - - //revert - assembly{ revert(0, 0) } - } - - function test_invalid() public { - - //revert - assembly{ invalid() } - } - - function test_stop() public { - - //revert - assembly{ stop() } - } - -} diff --git a/tests/solidity/migrations/1_initial_migration.js b/tests/solidity/migrations/1_initial_migration.js deleted file mode 100644 index ee2135d295..0000000000 --- a/tests/solidity/migrations/1_initial_migration.js +++ /dev/null @@ -1,5 +0,0 @@ -const Migrations = artifacts.require("Migrations"); - -module.exports = function(deployer) { - deployer.deploy(Migrations); -}; diff --git a/tests/solidity/migrations/2_opCodes_migration.js b/tests/solidity/migrations/2_opCodes_migration.js deleted file mode 100644 index 65c6b6dc14..0000000000 --- a/tests/solidity/migrations/2_opCodes_migration.js +++ /dev/null @@ -1,5 +0,0 @@ -var OpCodes = artifacts.require("./OpCodes.sol"); - -module.exports = function(deployer) { - deployer.deploy(OpCodes); -}; diff --git a/tests/solidity/test/opCodes.js b/tests/solidity/test/opCodes.js deleted file mode 100644 index 80abacef25..0000000000 --- a/tests/solidity/test/opCodes.js +++ /dev/null @@ -1,34 +0,0 @@ -const TodoList = artifacts.require('./OpCodes.sol') -const assert = require('assert') -let contractInstance -const Web3 = require('web3'); -const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')); -// const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:9545')); - -contract('OpCodes', (accounts) => { - beforeEach(async () => { - contractInstance = await TodoList.deployed() - }) - it('Should run without errors the majorit of opcodes', async () => { - await contractInstance.test() - await contractInstance.test_stop() - - }) - - it('Should throw invalid op code', async () => { - try{ - await contractInstance.test_invalid() - } - catch(error) { - console.error(error); - } - }) - - it('Should revert', async () => { - try{ - await contractInstance.test_revert() } - catch(error) { - console.error(error); - } - }) -}) diff --git a/tests/solidity/truffle-config.js b/tests/solidity/truffle-config.js deleted file mode 100644 index 3d13e0c449..0000000000 --- a/tests/solidity/truffle-config.js +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Use this file to configure your truffle project. It's seeded with some - * common settings for different networks and features like migrations, - * compilation and testing. Uncomment the ones you need or modify - * them to suit your project as necessary. - * - * More information about configuration can be found at: - * - * truffleframework.com/docs/advanced/configuration - * - * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider) - * to sign your transactions before they're sent to a remote public node. Infura API - * keys are available for free at: infura.io/register - * - * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate - * public/private key pairs. If you're publishing your code to GitHub make sure you load this - * phrase from a file you've .gitignored so it doesn't accidentally become public. - * - */ - -// const HDWalletProvider = require('truffle-hdwallet-provider'); -// const infuraKey = "fj4jll3k....."; -// -// const fs = require('fs'); -// const mnemonic = fs.readFileSync(".secret").toString().trim(); - -// module.exports = { -// /** -// * Networks define how you connect to your quai client and let you set the -// * defaults web3 uses to send transactions. If you don't specify one truffle -// * will spin up a development blockchain for you on port 9545 when you -// * run `develop` or `test`. You can ask a truffle command to use a specific -// * network from the command line, e.g -// * -// * $ truffle test --network -// */ -// -// networks: { -// // Useful for testing. The `development` name is special - truffle uses it by default -// // if it's defined here and no other network is specified at the command line. -// // You should run a client (like ganache-cli, quai or parity) in a separate terminal -// // tab if you use this network and you must also set the `host`, `port` and `network_id` -// // options below to some value. -// // -// // development: { -// // host: "127.0.0.1", // Localhost (default: none) -// // port: 8545, // Standard Quai port (default: none) -// // network_id: "*", // Any network (default: none) -// // }, -// -// // Another network with more advanced options... -// // advanced: { -// // port: 8777, // Custom port -// // network_id: 1342, // Custom network -// // gas: 8500000, // Gas sent with each transaction (default: ~6700000) -// // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) -// // from:
, // Account to send txs from (default: accounts[0]) -// // websockets: true // Enable EventEmitter interface for web3 (default: false) -// // }, -// -// // Useful for deploying to a public network. -// // NB: It's important to wrap the provider as a function. -// // ropsten: { -// // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/${infuraKey}`), -// // network_id: 3, // Ropsten's id -// // gas: 5500000, // Ropsten has a lower block limit than mainnet -// // confirmations: 2, // # of confs to wait between deployments. (default: 0) -// // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) -// // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) -// // }, -// -// // Useful for private networks -// // private: { -// // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), -// // network_id: 2111, // This network is yours, in the cloud. -// // production: true // Treats this network as if it was a public net. (default: false) -// // } -// }, -// -// // Set default mocha options here, use special reporters etc. -// mocha: { -// // timeout: 100000 -// }, -// -// // Configure your compilers -// compilers: { -// solc: { -// // version: "0.5.1", // Fetch exact version from solc-bin (default: truffle's version) -// // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) -// // settings: { // See the solidity docs for advice about optimization and evmVersion -// // optimizer: { -// // enabled: false, -// // runs: 200 -// // }, -// // } -// } -// } -// } -module.exports = { - networks: { - development: { - host: 'localhost', - port: 8545, - network_id: '*' - } - } -} diff --git a/tests/state_test.go b/tests/state_test.go deleted file mode 100644 index 84248bc6c7..0000000000 --- a/tests/state_test.go +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "bufio" - "bytes" - "fmt" - "reflect" - "testing" - - "github.com/dominant-strategies/go-quai/core/vm" -) - -func TestState(t *testing.T) { - t.Parallel() - - st := new(testMatcher) - // Long tests: - st.slow(`^stAttackTest/ContractCreationSpam`) - st.slow(`^stBadOpcode/badOpcodes`) - st.slow(`^stPreCompiledContracts/modexp`) - st.slow(`^stQuadraticComplexityTest/`) - st.slow(`^stStaticCall/static_Call50000`) - st.slow(`^stStaticCall/static_Return50000`) - st.slow(`^stSystemOperationsTest/CallRecursiveBomb`) - st.slow(`^stTransactionTest/Opcodes_TransactionInit`) - - // Very time consuming - st.skipLoad(`^stTimeConsuming/`) - - // Uses 1GB RAM per tested fork - st.skipLoad(`^stStaticCall/static_Call1MB`) - st.skipLoad(`^stQuadraticComplexityTest/QuadraticComplexitySolidity_CallDataCopy`) - // Broken tests: - // Expected failures: - - // Older tests were moved into LegacyTests - for _, dir := range []string{ - stateTestDir, - // legacy state tests are disabled, due to them not being - // regenerated for the no-sender-eoa change. - //legacyStateTestDir, - } { - st.walk(t, dir, func(t *testing.T, name string, test *StateTest) { - for _, subtest := range test.Subtests() { - subtest := subtest - key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index) - - t.Run(key+"/trie", func(t *testing.T) { - withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error { - _, _, err := test.Run(subtest, vmconfig, false) - if err != nil && len(test.json.Post[subtest.Fork][subtest.Index].ExpectException) > 0 { - // Ignore expected errors (TODO MariusVanDerWijden check error string) - return nil - } - return st.checkFailure(t, err) - }) - }) - t.Run(key+"/snap", func(t *testing.T) { - withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error { - snaps, statedb, err := test.Run(subtest, vmconfig, true) - if snaps != nil && statedb != nil { - if _, err := snaps.Journal(statedb.IntermediateRoot(false)); err != nil { - return err - } - } - if err != nil && len(test.json.Post[subtest.Fork][subtest.Index].ExpectException) > 0 { - // Ignore expected errors (TODO MariusVanDerWijden check error string) - return nil - } - return st.checkFailure(t, err) - }) - }) - } - }) - } -} - -// Transactions with gasLimit above this value will not get a VM trace on failure. -const traceErrorLimit = 400000 - -func withTrace(t *testing.T, gasLimit uint64, test func(vm.Config) error) { - // Use config from command line arguments. - config := vm.Config{} - err := test(config) - if err == nil { - return - } - - // Test failed, re-run with tracing enabled. - t.Error(err) - if gasLimit > traceErrorLimit { - t.Log("gas limit too high for EVM trace") - return - } - buf := new(bytes.Buffer) - w := bufio.NewWriter(buf) - tracer := vm.NewJSONLogger(&vm.LogConfig{DisableMemory: true}, w) - config.Debug, config.Tracer = true, tracer - err2 := test(config) - if !reflect.DeepEqual(err, err2) { - t.Errorf("different error for second run: %v", err2) - } - w.Flush() - if buf.Len() == 0 { - t.Log("no EVM operation logs generated") - } else { - t.Log("EVM operation log:\n" + buf.String()) - } - // t.Logf("EVM output: 0x%x", tracer.Output()) - // t.Logf("EVM error: %v", tracer.Error()) -} diff --git a/tests/state_test_util.go b/tests/state_test_util.go deleted file mode 100644 index 4f0240d0f3..0000000000 --- a/tests/state_test_util.go +++ /dev/null @@ -1,342 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "math/big" - "strings" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/common/hexutil" - "github.com/dominant-strategies/go-quai/common/math" - "github.com/dominant-strategies/go-quai/core" - "github.com/dominant-strategies/go-quai/core/rawdb" - "github.com/dominant-strategies/go-quai/core/state" - "github.com/dominant-strategies/go-quai/core/state/snapshot" - "github.com/dominant-strategies/go-quai/core/types" - "github.com/dominant-strategies/go-quai/core/vm" - "github.com/dominant-strategies/go-quai/crypto" - "github.com/dominant-strategies/go-quai/ethdb" - "github.com/dominant-strategies/go-quai/params" - "github.com/dominant-strategies/go-quai/rlp" - "golang.org/x/crypto/sha3" -) - -// StateTest checks transaction processing without block context. -type StateTest struct { - json stJSON -} - -// StateSubtest selects a specific configuration of a General State Test. -type StateSubtest struct { - Fork string - Index int -} - -func (t *StateTest) UnmarshalJSON(in []byte) error { - return json.Unmarshal(in, &t.json) -} - -type stJSON struct { - Env stEnv `json:"env"` - Pre core.GenesisAlloc `json:"pre"` - Tx stTransaction `json:"transaction"` - Out hexutil.Bytes `json:"out"` - Post map[string][]stPostState `json:"post"` -} - -type stPostState struct { - Root common.UnprefixedHash `json:"hash"` - Logs common.UnprefixedHash `json:"logs"` - TxBytes hexutil.Bytes `json:"txbytes"` - ExpectException string `json:"expectException"` - Indexes struct { - Data int `json:"data"` - Gas int `json:"gas"` - Value int `json:"value"` - } -} - -//go:generate gencodec -type stEnv -field-override stEnvMarshaling -out gen_stenv.go - -type stEnv struct { - Coinbase common.Address `json:"currentCoinbase" gencodec:"required"` - Difficulty *big.Int `json:"currentDifficulty" gencodec:"required"` - GasLimit uint64 `json:"currentGasLimit" gencodec:"required"` - Number uint64 `json:"currentNumber" gencodec:"required"` - Timestamp uint64 `json:"currentTimestamp" gencodec:"required"` - BaseFee *big.Int `json:"currentBaseFee" gencodec:"optional"` -} - -type stEnvMarshaling struct { - Coinbase common.UnprefixedAddress - Difficulty *math.HexOrDecimal256 - GasLimit math.HexOrDecimal64 - Number math.HexOrDecimal64 - Timestamp math.HexOrDecimal64 - BaseFee *math.HexOrDecimal256 -} - -//go:generate gencodec -type stTransaction -field-override stTransactionMarshaling -out gen_sttransaction.go - -type stTransaction struct { - GasPrice *big.Int `json:"gasPrice"` - MaxFeePerGas *big.Int `json:"maxFeePerGas"` - MaxPriorityFeePerGas *big.Int `json:"maxPriorityFeePerGas"` - Nonce uint64 `json:"nonce"` - To string `json:"to"` - Data []string `json:"data"` - AccessLists []*types.AccessList `json:"accessLists,omitempty"` - GasLimit []uint64 `json:"gasLimit"` - Value []string `json:"value"` - PrivateKey []byte `json:"secretKey"` -} - -type stTransactionMarshaling struct { - GasPrice *math.HexOrDecimal256 - MaxFeePerGas *math.HexOrDecimal256 - MaxPriorityFeePerGas *math.HexOrDecimal256 - Nonce math.HexOrDecimal64 - GasLimit []math.HexOrDecimal64 - PrivateKey hexutil.Bytes -} - -// GetChainConfig takes a fork definition and returns a chain config. -func GetChainConfig(forkString string) (baseConfig *params.ChainConfig, err error) { - var ( - splitForks = strings.Split(forkString, "+") - ok bool - baseName, _ = splitForks[0], splitForks[1:] - ) - if baseConfig, ok = Forks[baseName]; !ok { - return nil, UnsupportedForkError{baseName} - } - return baseConfig, nil -} - -// Subtests returns all valid subtests of the test. -func (t *StateTest) Subtests() []StateSubtest { - var sub []StateSubtest - for fork, pss := range t.json.Post { - for i := range pss { - sub = append(sub, StateSubtest{fork, i}) - } - } - return sub -} - -// Run executes a specific subtest and verifies the post-state and logs -func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config, snapshotter bool) (*snapshot.Tree, *state.StateDB, error) { - snaps, statedb, root, err := t.RunNoVerify(subtest, vmconfig, snapshotter) - if err != nil { - return snaps, statedb, err - } - post := t.json.Post[subtest.Fork][subtest.Index] - // N.B: We need to do this in a two-step process, because the first Commit takes care - // of suicides, and we need to touch the coinbase _after_ it has potentially suicided. - if root != common.Hash(post.Root()) { - return snaps, statedb, fmt.Errorf("post state root mismatch: got %x, want %x", root, post.Root()) - } - if logs := rlpHash(statedb.Logs()); logs != common.Hash(post.Logs) { - return snaps, statedb, fmt.Errorf("post state logs hash mismatch: got %x, want %x", logs, post.Logs) - } - return snaps, statedb, nil -} - -// RunNoVerify runs a specific subtest and returns the statedb and post-state root -func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapshotter bool) (*snapshot.Tree, *state.StateDB, common.Hash, error) { - config, err := GetChainConfig(subtest.Fork) - if err != nil { - return nil, nil, common.Hash{}, UnsupportedForkError{subtest.Fork} - } - block := t.genesis(config).ToBlock(nil) - snaps, statedb := MakePreState(rawdb.NewMemoryDatabase(), t.json.Pre, snapshotter) - - var baseFee *big.Int - baseFee = t.json.Env.BaseFee - if baseFee == nil { - // Retesteth uses `0x10` for genesis baseFee. Therefore, it defaults to - // parent - 2 : 0xa as the basefee for 'this' context. - baseFee = big.NewInt(0x0a) - } - - post := t.json.Post[subtest.Fork][subtest.Index] - msg, err := t.json.Tx.toMessage(post, baseFee) - if err != nil { - return nil, nil, common.Hash{}, err - } - - // Try to recover tx with current signer - if len(post.TxBytes) != 0 { - var ttx types.Transaction - err := ttx.UnmarshalBinary(post.TxBytes) - if err != nil { - return nil, nil, common.Hash{}, err - } - - if _, err := types.Sender(types.LatestSigner(config), &ttx); err != nil { - return nil, nil, common.Hash{}, err - } - } - - // Prepare the EVM. - txContext := core.NewEVMTxContext(msg) - context := core.NewEVMBlockContext(block.Header(), nil, &t.json.Env.Coinbase()) - context.GetHash = vmTestBlockHash - context.BaseFee() = baseFee - evm := vm.NewEVM(context, txContext, statedb, config, vmconfig) - - // Execute the message. - snapshot := statedb.Snapshot() - gaspool := new(core.GasPool) - gaspool.AddGas(block.GasLimit()) - if _, err := core.ApplyMessage(evm, msg, gaspool); err != nil { - statedb.RevertToSnapshot(snapshot) - } - - // Commit block - statedb.Commit(true) - // Add 0-value mining reward. This only makes a difference in the cases - // where - // - the coinbase suicided, or - // - there are only 'bad' transactions, which aren't executed. In those cases, - // the coinbase gets no txfee, so isn't created, and thus needs to be touched - statedb.AddBalance(block.Coinbase(), new(big.Int)) - // And _now_ get the state root - root := statedb.IntermediateRoot(true) - return snaps, statedb, root, nil -} - -func (t *StateTest) gasLimit(subtest StateSubtest) uint64 { - return t.json.Tx.GasLimit[t.json.Post[subtest.Fork][subtest.Index].Indexes.Gas] -} - -func MakePreState(db ethdb.Database, accounts core.GenesisAlloc, snapshotter bool) (*snapshot.Tree, *state.StateDB) { - sdb := state.NewDatabase(db) - statedb, _ := state.New(common.Hash{}, sdb, nil) - for addr, a := range accounts { - statedb.SetCode(addr, a.Code) - statedb.SetNonce(addr, a.Nonce()) - statedb.SetBalance(addr, a.Balance) - for k, v := range a.Storage { - statedb.SetState(addr, k, v) - } - } - // Commit and re-open to start with a clean state. - root, _ := statedb.Commit(false) - - var snaps *snapshot.Tree - if snapshotter { - snaps, _ = snapshot.New(db, sdb.TrieDB(), 1, root, false, true, false) - } - statedb, _ = state.New(root, sdb, snaps) - return snaps, statedb -} - -func (t *StateTest) genesis(config *params.ChainConfig) *core.Genesis { - return &core.Genesis{ - Config: config, - Coinbase: t.json.Env.Coinbase(), - Difficulty: t.json.Env.Difficulty(), - GasLimit: t.json.Env.GasLimit(), - Number: t.json.Env.Number(), - Timestamp: t.json.Env.Timestamp, - Alloc: t.json.Pre, - } -} - -func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (core.Message, error) { - // Derive sender from private key if present. - var from common.Address - if len(tx.PrivateKey) > 0 { - key, err := crypto.ToECDSA(tx.PrivateKey) - if err != nil { - return nil, fmt.Errorf("invalid private key: %v", err) - } - from = crypto.PubkeyToAddress(key.PublicKey) - } - // Parse recipient if present. - var to *common.Address - if tx.To != "" { - to = new(common.Address) - if err := to.UnmarshalText([]byte(tx.To)); err != nil { - return nil, fmt.Errorf("invalid to address: %v", err) - } - } - - // Get values specific to this post state. - if ps.Indexes.Data > len(tx.Data) { - return nil, fmt.Errorf("tx data index %d out of bounds", ps.Indexes.Data) - } - if ps.Indexes.Value > len(tx.Value) { - return nil, fmt.Errorf("tx value index %d out of bounds", ps.Indexes.Value) - } - if ps.Indexes.Gas > len(tx.GasLimit()) { - return nil, fmt.Errorf("tx gas limit index %d out of bounds", ps.Indexes.Gas) - } - dataHex := tx.Data[ps.Indexes.Data] - valueHex := tx.Value[ps.Indexes.Value] - gasLimit := tx.GasLimit[ps.Indexes.Gas] - value := new(big.Int) - if valueHex != "0x" { - v, ok := math.ParseBig256(valueHex) - if !ok { - return nil, fmt.Errorf("invalid tx value %q", valueHex) - } - value = v - } - data, err := hex.DecodeString(strings.TrimPrefix(dataHex, "0x")) - if err != nil { - return nil, fmt.Errorf("invalid tx data %q", dataHex) - } - var accessList types.AccessList - if tx.AccessLists != nil && tx.AccessLists[ps.Indexes.Data] != nil { - accessList = *tx.AccessLists[ps.Indexes.Data] - } - // If baseFee provided, set gasPrice to effectiveGasPrice. - gasPrice := tx.GasPrice - if baseFee != nil { - if tx.MaxFeePerGas == nil { - tx.MaxFeePerGas = gasPrice - } - if tx.MaxFeePerGas == nil { - tx.MaxFeePerGas = new(big.Int) - } - if tx.MaxPriorityFeePerGas == nil { - tx.MaxPriorityFeePerGas = tx.MaxFeePerGas - } - gasPrice = math.BigMin(new(big.Int).Add(tx.MaxPriorityFeePerGas, baseFee), - tx.MaxFeePerGas) - } - if gasPrice == nil { - return nil, fmt.Errorf("no gas price provided") - } - - msg := types.NewMessage(from, to, tx.Nonce(), value, gasLimit, gasPrice, - tx.MaxFeePerGas, tx.MaxPriorityFeePerGas, data, accessList, true) - return msg, nil -} - -func rlpHash(x interface{}) (h common.Hash) { - hw := sha3.NewLegacyKeccak256() - rlp.Encode(hw, x) - hw.Sum(h[:0]) - return h -} diff --git a/tests/transaction_test.go b/tests/transaction_test.go deleted file mode 100644 index 55f331e883..0000000000 --- a/tests/transaction_test.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "testing" - - "github.com/dominant-strategies/go-quai/params" -) - -func TestTransaction(t *testing.T) { - t.Parallel() - - txt := new(testMatcher) - // These can't be parsed, invalid hex in RLP - txt.skipLoad("^ttWrongRLP/.*") - // We don't allow more than uint64 in gas amount - // This is a pseudo-consensus vulnerability, but not in practice - // because of the gas limit - txt.skipLoad("^ttGasLimit/TransactionWithGasLimitxPriceOverflow.json") - // We _do_ allow more than uint64 in gas price, as opposed to the tests - // This is also not a concern, as long as tx.Cost() uses big.Int for - // calculating the final cozt - txt.skipLoad(".*TransactionWithGasPriceOverflow.*") - - // The nonce is too large for uint64. Not a concern, it means go-quai won't - // accept transactions at a certain point in the distant future - txt.skipLoad("^ttNonce/TransactionWithHighNonce256.json") - - // The value is larger than uint64, which according to the test is invalid. - // go-quai accepts it, which is not a consensus issue since we use big.Int's - // internally to calculate the cost - txt.skipLoad("^ttValue/TransactionWithHighValueOverflow.json") - txt.walk(t, transactionTestDir, func(t *testing.T, name string, test *TransactionTest) { - cfg := params.ColosseumChainConfig - if err := txt.checkFailure(t, test.Run(cfg)); err != nil { - t.Error(err) - } - }) -} diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go deleted file mode 100644 index 86f99c9b11..0000000000 --- a/tests/transaction_test_util.go +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "fmt" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/common/hexutil" - "github.com/dominant-strategies/go-quai/core" - "github.com/dominant-strategies/go-quai/core/types" - "github.com/dominant-strategies/go-quai/params" - "github.com/dominant-strategies/go-quai/rlp" -) - -// TransactionTest checks RLP decoding and sender derivation of transactions. -type TransactionTest struct { - RLP hexutil.Bytes `json:"rlp"` -} - -type ttFork struct { - Sender common.UnprefixedAddress `json:"sender"` - Hash common.UnprefixedHash `json:"hash"` -} - -func (tt *TransactionTest) Run(config *params.ChainConfig) error { - validateTx := func(rlpData hexutil.Bytes, signer types.Signer) (*common.Address, *common.Hash, error) { - tx := new(types.Transaction) - if err := rlp.DecodeBytes(rlpData, tx); err != nil { - return nil, nil, err - } - sender, err := types.Sender(signer, tx) - if err != nil { - return nil, nil, err - } - // Intrinsic gas - requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil) - if err != nil { - return nil, nil, err - } - if requiredGas > tx.Gas() { - return nil, nil, fmt.Errorf("insufficient gas ( %d < %d )", tx.Gas(), requiredGas) - } - h := tx.Hash() - return &sender, &h, nil - } - - for _, testcase := range []struct { - name string - signer types.Signer - fork ttFork - }{ - {}, - } { - sender, txhash, err := validateTx(tt.RLP, testcase.signer) - - if testcase.fork.Sender == (common.UnprefixedAddress{}) { - if err == nil { - return fmt.Errorf("expected error, got none (address %v)[%v]", sender.String(), testcase.name) - } - continue - } - // Should resolve the right address - if err != nil { - return fmt.Errorf("got error, expected none: %v", err) - } - if sender == nil { - return fmt.Errorf("sender was nil, should be %x", common.Address(testcase.fork.Sender)) - } - if *sender != common.Address(testcase.fork.Sender) { - return fmt.Errorf("sender mismatch: got %x, want %x", sender, testcase.fork.Sender) - } - if txhash == nil { - return fmt.Errorf("txhash was nil, should be %x", common.Hash(testcase.fork.Hash)) - } - if *txhash != common.Hash(testcase.fork.Hash) { - return fmt.Errorf("hash mismatch: got %x, want %x", *txhash, testcase.fork.Hash) - } - } - return nil -} diff --git a/tests/vm_test.go b/tests/vm_test.go deleted file mode 100644 index 65ac52e63b..0000000000 --- a/tests/vm_test.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "testing" - - "github.com/dominant-strategies/go-quai/core/vm" -) - -func TestVM(t *testing.T) { - t.Parallel() - vmt := new(testMatcher) - vmt.slow("^vmPerformance") - vmt.fails("^vmSystemOperationsTest.json/createNameRegistrator$", "fails without parallel execution") - - vmt.walk(t, vmTestDir, func(t *testing.T, name string, test *VMTest) { - withTrace(t, test.json.Exec.GasLimit(), func(vmconfig vm.Config) error { - return vmt.checkFailure(t, test.Run(vmconfig, false)) - }) - withTrace(t, test.json.Exec.GasLimit(), func(vmconfig vm.Config) error { - return vmt.checkFailure(t, test.Run(vmconfig, true)) - }) - }) -} diff --git a/tests/vm_test_util.go b/tests/vm_test_util.go deleted file mode 100644 index e8566990a6..0000000000 --- a/tests/vm_test_util.go +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package tests - -import ( - "bytes" - "encoding/json" - "fmt" - "math/big" - - "github.com/dominant-strategies/go-quai/common" - "github.com/dominant-strategies/go-quai/common/hexutil" - "github.com/dominant-strategies/go-quai/common/math" - "github.com/dominant-strategies/go-quai/core" - "github.com/dominant-strategies/go-quai/core/rawdb" - "github.com/dominant-strategies/go-quai/core/state" - "github.com/dominant-strategies/go-quai/core/vm" - "github.com/dominant-strategies/go-quai/crypto" - "github.com/dominant-strategies/go-quai/params" -) - -// VMTest checks EVM execution without block or transaction context. -type VMTest struct { - json vmJSON -} - -func (t *VMTest) UnmarshalJSON(data []byte) error { - return json.Unmarshal(data, &t.json) -} - -type vmJSON struct { - Env stEnv `json:"env"` - Exec vmExec `json:"exec"` - Logs common.UnprefixedHash `json:"logs"` - GasRemaining *math.HexOrDecimal64 `json:"gas"` - Out hexutil.Bytes `json:"out"` - Pre core.GenesisAlloc `json:"pre"` - Post core.GenesisAlloc `json:"post"` - PostStateRoot common.Hash `json:"postStateRoot"` -} - -//go:generate gencodec -type vmExec -field-override vmExecMarshaling -out gen_vmexec.go - -type vmExec struct { - Address common.Address `json:"address" gencodec:"required"` - Caller common.Address `json:"caller" gencodec:"required"` - Origin common.Address `json:"origin" gencodec:"required"` - Code []byte `json:"code" gencodec:"required"` - Data []byte `json:"data" gencodec:"required"` - Value *big.Int `json:"value" gencodec:"required"` - GasLimit uint64 `json:"gas" gencodec:"required"` - GasPrice *big.Int `json:"gasPrice" gencodec:"required"` -} - -type vmExecMarshaling struct { - Address common.UnprefixedAddress - Caller common.UnprefixedAddress - Origin common.UnprefixedAddress - Code hexutil.Bytes - Data hexutil.Bytes - Value *math.HexOrDecimal256 - GasLimit math.HexOrDecimal64 - GasPrice *math.HexOrDecimal256 -} - -func (t *VMTest) Run(vmconfig vm.Config, snapshotter bool) error { - snaps, statedb := MakePreState(rawdb.NewMemoryDatabase(), t.json.Pre, snapshotter) - if snapshotter { - preRoot := statedb.IntermediateRoot(false) - defer func() { - if _, err := snaps.Journal(preRoot); err != nil { - panic(err) - } - }() - } - ret, gasRemaining, err := t.exec(statedb, vmconfig) - - if t.json.GasRemaining == nil { - if err == nil { - return fmt.Errorf("gas unspecified (indicating an error), but VM returned no error") - } - if gasRemaining > 0 { - return fmt.Errorf("gas unspecified (indicating an error), but VM returned gas remaining > 0") - } - return nil - } - // Test declares gas, expecting outputs to match. - if !bytes.Equal(ret, t.json.Out) { - return fmt.Errorf("return data mismatch: got %x, want %x", ret, t.json.Out) - } - if gasRemaining != uint64(*t.json.GasRemaining) { - return fmt.Errorf("remaining gas %v, want %v", gasRemaining, *t.json.GasRemaining) - } - for addr, account := range t.json.Post { - for k, wantV := range account.Storage { - if haveV := statedb.GetState(addr, k); haveV != wantV { - return fmt.Errorf("wrong storage value at %x:\n got %x\n want %x", k, haveV, wantV) - } - } - } - // if root := statedb.IntermediateRoot(false); root != t.json.PostStateRoot { - // return fmt.Errorf("post state root mismatch, got %x, want %x", root, t.json.PostStateRoot) - // } - if logs := rlpHash(statedb.Logs()); logs != common.Hash(t.json.Logs) { - return fmt.Errorf("post state logs hash mismatch: got %x, want %x", logs, t.json.Logs) - } - return nil -} - -func (t *VMTest) exec(statedb *state.StateDB, vmconfig vm.Config) ([]byte, uint64, error) { - evm := t.newEVM(statedb, vmconfig) - e := t.json.Exec - return evm.Call(vm.AccountRef(e.Caller), e.Address, e.Data, e.GasLimit(), e.Value) -} - -func (t *VMTest) newEVM(statedb *state.StateDB, vmconfig vm.Config) *vm.EVM { - initialCall := true - canTransfer := func(db vm.StateDB, address common.Address, amount *big.Int) bool { - if initialCall { - initialCall = false - return true - } - return core.CanTransfer(db, address, amount) - } - transfer := func(db vm.StateDB, sender, recipient common.Address, amount *big.Int) {} - txContext := vm.TxContext{ - Origin: t.json.Exec.Origin, - GasPrice: t.json.Exec.GasPrice, - } - context := vm.BlockContext{ - CanTransfer: canTransfer, - Transfer: transfer, - GetHash: vmTestBlockHash, - Coinbase: t.json.Env.Coinbase(), - BlockNumber: new(big.Int).SetUint64(t.json.Env.Number()), - Time: new(big.Int).SetUint64(t.json.Env.Timestamp), - GasLimit: t.json.Env.GasLimit(), - Difficulty: t.json.Env.Difficulty(), - } - vmconfig.NoRecursion = true - return vm.NewEVM(context, txContext, statedb, params.MainnetChainConfig, vmconfig) -} - -func vmTestBlockHash(n uint64) common.Hash { - return common.BytesToHash(crypto.Keccak256([]byte(big.NewInt(int64(n)).String()))) -}