-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathwallet.test.ts
More file actions
80 lines (70 loc) · 2.14 KB
/
wallet.test.ts
File metadata and controls
80 lines (70 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { Chain, Account } from "../src";
import { generateTapos } from "../src/utils";
import { importKey, signatureProvider, createKey } from "../src/wallet";
describe("test wallet", () => {
let chain: Chain;
let account: Account;
let chainName = process.env.CHAIN_NAME || "WAX";
beforeAll(async () => {
chain = await Chain.setupChain(chainName);
account = await chain.system.createAccount("testaccount1");
}, 60000);
afterAll(async () => {
await chain.clear();
}, 10000);
it("import key", async () => {
importKey("5JLA28jodzEmhdgGsdC6s8zkWNBTKmNtxB9RywHoKUQ6FpAmRMG");
const availablePubKeys = await signatureProvider.getAvailableKeys();
expect(availablePubKeys.length).toBe(2);
await account.updateAuth(
"testauth",
"active",
1,
[
{
key: "EOS8cExDTKMmr8Drk6iMiB35D4SrEmRupvxXYwdjqqrhN58JjiXBf",
weight: 1,
},
],
[]
);
await account.linkAuth("eosio.token", "transfer", "testauth");
const transferTransaction = await chain.api.transact(
{
// should able to push transaction with new added key
actions: [
{
account: "eosio.token",
name: "transfer",
authorization: [
{
actor: account.name,
permission: "testauth",
},
],
data: {
from: account.name,
to: "acc11.test",
quantity: chain.coreSymbol.convertAssetString(0.1),
memo: "test",
},
},
],
},
generateTapos()
);
expect(transferTransaction.processed.action_traces[0].act.account).toBe(
"eosio.token"
);
expect(transferTransaction.processed.action_traces[0].act.name).toBe(
"transfer"
);
});
it("create new key", async () => {
const newKey = createKey();
const newPublicKey = newKey.publicKey.toString();
expect(newPublicKey.startsWith("PUB_K1_")).toBeTruthy();
const availablePubKeys = await signatureProvider.getAvailableKeys();
expect(availablePubKeys.includes(newPublicKey)).toBe(true);
});
});