-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbin.ts
More file actions
65 lines (59 loc) · 2.14 KB
/
Copy pathbin.ts
File metadata and controls
65 lines (59 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// tslint:disable:no-console
import { generateTestSuite, TestSuite, stateTestRunner, RunnerArgs } from './lib'
import { basicEvmTestSuite } from './basic-evm'
import { generateRealisticTestSuite } from './realistic'
import { getStateTest } from './state-test'
const fs = require('fs')
const yaml = require('js-yaml')
const testing = require('ethereumjs-testing')
async function main() {
const args = process.argv
if (args.length === 4 && args[2] === '--stateTest') {
const testName = args[3]
const runnerArgs: RunnerArgs = {
stateless: true,
fork: 'Petersburg',
test: testName,
scout: 'true',
dist: '?',
forkConfig: 'Petersburg',
jsontrace: false,
debug: false,
data: '',
gasLimit: 0,
value: 0,
}
const test = await getStateTest(testName)
const testSuite = await stateTestRunner(runnerArgs, test)
writeScoutConfig(testSuite, testName + '.yaml', 'build/evm_with_keccak.wasm')
} else if (args.length === 4 && args[2] === '--realistic') {
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()
writeScoutConfig(testSuite, 'basic-evm.yaml', 'build/evm_with_keccak.wasm')
} else {
const testSuite = await generateTestSuite()
writeScoutConfig(testSuite, 'turbo-token.yaml', 'build/token_with_keccak.wasm')
}
}
function writeScoutConfig(data: TestSuite, outPath: string, wasmPath: string) {
const testSuite = {
beacon_state: {
execution_scripts: [wasmPath],
},
shard_pre_state: {
exec_env_states: [data.preStateRoot.toString('hex')],
},
shard_blocks: [{ env: 0, data: data.blockData.toString('hex') }],
shard_post_state: {
exec_env_states: [data.postStateRoot.toString('hex')],
},
}
const serializedTestSuite = yaml.safeDump(testSuite)
fs.writeFileSync(outPath, serializedTestSuite)
}
main()
.then(() => {})
.catch((e: Error) => console.log(e))