-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump.spec.ts
More file actions
45 lines (40 loc) · 1.79 KB
/
dump.spec.ts
File metadata and controls
45 lines (40 loc) · 1.79 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
import { File } from 'atma-io';
import { TestUtils } from './TestUtils';
import { HardhatProvider } from '@dequanto/hardhat/HardhatProvider';
import { ContractReader } from '@dequanto/contracts/ContractReader';
const provider = new HardhatProvider();
const client = provider.client('localhost');
const metaOriginal = './cache/dump/DumpDemo.original.json';
const metaCloned = './cache/dump/DumpDemo.cloned.json';
UTest({
$config: {
timeout: 20_000,
},
async $before () {
await TestUtils.start();
},
async '!should install contracts storage' () {
let { stdout, stderr } = await TestUtils.execute(`npx atma act ./actions/dump.act.ts -q "deploy original"`);
let { address } = await File.readAsync<any>(metaOriginal);
let reader = new ContractReader(client);
let foo = await reader.readAsync(address, '_foo() returns (uint256)');
eq_(foo, 5n);
let name = await reader.readAsync(address, '_name() returns (string)');
eq_(name, 'Foo');
},
async 'should dump contracts storage' () {
await TestUtils.execute(`npx atma act ./actions/dump.act.ts -q "dump original"`);
let json = await File.readAsync('./cache/dump/data/DumpDemo.json');
has_(json, { _name: 'Foo' });
},
async 'should clone contract' () {
await TestUtils.execute(`npx atma act ./actions/dump.act.ts -q "redeploy"`);
let { address } = await File.readAsync<{ address }>(metaCloned);
let reader = new ContractReader(client);
let foo = await reader.readAsync(address, '_foo() returns (uint256)');
eq_(foo, 0n);
await TestUtils.execute(`npx atma act ./actions/dump.act.ts -q "restore"`);
foo = await reader.readAsync(address, '_foo() returns (uint256)');
eq_(foo, 5n);
}
});