Skip to content

Commit

Permalink
Let users select their fixture in basic evm test. (#62)
Browse files Browse the repository at this point in the history
* Let users select their fixture in basic evm test.

* Update src/relayer/basic-evm.ts

Co-Authored-By: Sina Mahmoodi <[email protected]>

* fix linter issue

* add an SLOAD+MSTORE8

Co-authored-by: Sina Mahmoodi <[email protected]>
  • Loading branch information
gballet and s1na committed Jan 13, 2020
1 parent c211f43 commit 570634b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/relayer/basic-evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {
} from './lib'
const Trie = require('merkle-patricia-tree/secure')

export async function basicEvmTestSuite(): Promise<TestSuite> {
export async function basicEvmTestSuite(p: string = 'fixture/add.json'): Promise<TestSuite> {
const trie = new Trie()

const test = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixture/add.json'), 'utf-8'))
const test = JSON.parse(fs.readFileSync(path.join(__dirname, p), 'utf-8'))
const [accounts, codeHashes, bytecode] = await getTestsAccounts(trie, test)

const preStateRoot = trie.root
Expand Down
4 changes: 2 additions & 2 deletions src/relayer/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ async function main() {
const rpcData = JSON.parse(fs.readFileSync(process.argv[3]))
const testSuite = await generateRealisticTestSuite(rpcData)
writeScoutConfig(testSuite, 'turbo-token-realistic.yaml', 'build/token_with_keccak.wasm')
} else if (args.length === 3 && args[2] === '--basicEvm') {
const testSuite = await basicEvmTestSuite()
} else if (args.length >= 3 && args[2] === '--basicEvm') {
const testSuite = await basicEvmTestSuite(args[3])
writeScoutConfig(testSuite, 'basic-evm.yaml', 'build/evm_with_keccak.wasm')
} else {
const testSuite = await generateTestSuite()
Expand Down
36 changes: 36 additions & 0 deletions src/relayer/fixture/add_store.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"_comment": "ADD two values, SSTORE result, and RETURN",
"returnValue": "0x05",
"pre" : {
"0x095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x600260030160005560005460005360016000f3",
"nonce" : "0x00",
"storage" : {
"0x00": "0x01"
}
},
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
},
"transaction" : {
"data" : [
"0x"
],
"gasLimit" : [
"0x061a80"
],
"gasPrice" : "0x01",
"nonce" : "0x00",
"secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : [
"0x0186a0"
]
}
}

0 comments on commit 570634b

Please sign in to comment.