git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 37461769a82fe6533209cae948cd10a1cd8789bf

Sample test tool for VM phase2

Alex Beregszaszi committed on 8/23/2016, 12:27:46 AM
Parent: e74b3f639022db04c2ec7782c0b9320add8b05db

Files changed

test.jsadded
test.jsView
@@ -1,0 +1,41 @@
1+const Kernel = require('./index.js')
2+const Environment = require('./environment.js')
3+
4+const environment = new Environment()
5+const kernel = new Kernel(environment)
6+
7+const Address = require('./address.js')
8+const U256 = require('./u256.js')
9+
10+const fs = require('fs')
11+
12+environment.addAccount(new Address('0x1234567890134561111123412341234123412341'), { balance: new U256('100000000000000000') })
13+//environment.addAccount(new Address('0x4123412341234123411234567890134561111123'), { code: Uint8Array.from(fs.readFileSync('identity.wasm')) })
14+
15+environment.addAccount(new Address('0xbe862ad9abfe6f22bcb087716c7d89a26051f74c'), { balance: new U256('100000000000000000') })
16+var tx = new Buffer('f8e380648203e88080b8977f4e616d65526567000000000000000000000000000000000000000000000000003057307f4e616d6552656700000000000000000000000000000000000000000000000000573360455760415160566000396000f20036602259604556330e0f600f5933ff33560f601e5960003356576000335700604158600035560f602b590033560f603659600033565733600035576000353357001ca0b8b9fedc076110cd002224a942e9d7099e4a626ebf66cd9301fc18e2c1181806a04e270be511d42189baf14599eb8d6eb5037ab105032dd3e0fa05b43dad4cb4c2', 'hex')
17+console.log(kernel.runTx(tx, environment))
18+
19+// deploy contract
20+let ret = kernel.runTx({
21+ nonce: new U256(3),
22+ from: new Address('0x1234567890134561111123412341234123412341'),
23+ to: new Address('0x0000000000000000000000000000000000000000'),
24+ value: new U256('100'),
25+ gasLimit: new U256('1000000000'),
26+ gasPrice: new U256(1),
27+ data: Uint8Array.from(fs.readFileSync('identity.wasm'))
28+}, environment)
29+console.log('Account created: ' + ret.accountCreated)
30+
31+ret = kernel.runTx({
32+ nonce: new U256(4),
33+ from: new Address('0x1234567890134561111123412341234123412341'),
34+ to: ret.accountCreated, //new Address('0x4123412341234123411234567890134561111123'),
35+ value: new U256('100'),
36+ gasLimit: new U256('1000000000'),
37+ gasPrice: new U256(1),
38+ data: Uint8Array.from(new Buffer('spartaaaa'))
39+}, environment)
40+
41+console.log('Return value: ' + ret.returnValue)

Built with git-ssb-web