-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheosio.faucet.spec.js
50 lines (41 loc) · 1.5 KB
/
eosio.faucet.spec.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
import { TimePointSec, Name } from "@greymass/eosio";
import { Blockchain } from "@proton/vert"
import { it, describe, beforeEach } from "node:test";
import assert from 'node:assert';
// Vert EOS VM
const blockchain = new Blockchain()
// contracts
const contract = blockchain.createContract('eosio.faucet', 'eosio.faucet', true);
blockchain.createAccounts('myaccount', 'anyaccount');
// one-time setup
beforeEach(async () => {
blockchain.setTime(TimePointSec.from("2023-04-01T00:00:00.000"));
});
function get_history(id) {
const scope = Name.from('eosio.faucet').value.value;
return contract.tables.devices(scope).getTableRow(BigInt(id));
}
describe('eosio.faucet', () => {
// it("send", async () => {
// await contract.actions.send(["myaccount"]).send("anyaccount");
// assert.deepEqual(get_history(1).receiver, "myaccount");
// });
// it("error: account does not exists", async () => {
// const action = contract.actions.send(["invalid"]).send();
// await expectToThrow(action, /faucet::send: [to] account does not exist/);
// });
});
/**
* Expect a promise to throw an error with a specific message.
* @param promise - The promise to await.
* @param {string} errorMsg - The error message that we expect to see.
*/
const expectToThrow = async (promise, errorMsg) => {
try {
await promise
assert.fail('Expected promise to throw an error');
} catch (e) {
if ( errorMsg ) assert.match(e.message, errorMsg);
else assert.fail('Expected promise to throw an error');
}
}