-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtelos.system.test.js
91 lines (81 loc) · 2.44 KB
/
telos.system.test.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const { loadConfig, Blockchain } = require("@klevoya/hydra");
const config = loadConfig("hydra.yml");
const bpJson = JSON.stringify(require(`./bp.json`), null, 2);
// #define TELOS in contract to build the contract for Telos
// Telos has a different producer_info structure
describe("telos.system", () => {
let blockchain = new Blockchain(config);
let eosio = blockchain.accounts.eosio;
let tester = blockchain.createAccount(`bpintegrity`);
let bpAccount = blockchain.createAccount(`maltablockbp`);
beforeAll(async () => {
tester.setContract(blockchain.contractTemplates[`bpintegrity`]);
eosio.setContract(blockchain.contractTemplates[`telos.system`]);
tester.updateAuth(`active`, `owner`, {
accounts: [
{
permission: {
actor: tester.accountName,
permission: `eosio.code`,
},
weight: 1,
},
],
});
});
beforeEach(async () => {
tester.resetTables();
});
it("can register a TELOS bp producer format", async () => {
expect.assertions(1);
await eosio.contract.regproducer(
{
producer: bpAccount.accountName,
producer_key: "EOS68qB2xe87B4zGU96KD4z9UY3BeYRHpkaytRnxA11494KBdHZh2",
url: "https://null",
location: 0,
},
[{ actor: bpAccount.accountName, permission: `active` }]
);
expect(eosio.getTableRowsScoped(`producers`)[`eosio`]).toEqual([
{
is_active: true,
kick_penalty_hours: 0,
kick_reason: "",
kick_reason_id: 0,
last_claim_time: "2000-01-01T00:00:00.000",
last_time_kicked: "2000-01-01T00:00:00.000",
lifetime_missed_blocks: 0,
lifetime_produced_blocks: 0,
location: 0,
missed_blocks_per_rotation: 0,
owner: "maltablockbp",
producer_key:
"PUB_K1_68qB2xe87B4zGU96KD4z9UY3BeYRHpkaytRnxA11494K7BkdRq",
times_kicked: 0,
total_votes: 0,
unpaid_blocks: 0,
unreg_reason: "",
url: "https://null",
},
]);
});
it("can submit bp.json", async () => {
expect.assertions(1);
await tester.contract.setbpjson(
{
owner: bpAccount.accountName,
json: bpJson,
},
[{ actor: bpAccount.accountName, permission: `active` }]
);
expect(
tester.getTableRowsScoped(`sysadminjson`)[tester.accountName]
).toEqual([
{
owner: `maltablockbp`,
json: bpJson,
},
]);
});
});