-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrailgun-smart-wallet-transact.test.ts
More file actions
65 lines (51 loc) · 2.09 KB
/
railgun-smart-wallet-transact.test.ts
File metadata and controls
65 lines (51 loc) · 2.09 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
import { BigInt, Bytes } from "@graphprotocol/graph-ts";
import { assert, describe, test, clearStore, beforeAll, afterAll } from "matchstick-as/assembly/index";
import { handleTransact } from "../src/railgun-smart-wallet";
import { createTransactEvent, createTransactCiphertextTuple } from "./railgun-smart-wallet-utils";
describe("Transact event tests", () => {
beforeAll(() => {
const ciphertextTuple = createTransactCiphertextTuple(
[
Bytes.fromHexString("0x01"),
Bytes.fromHexString("0x02"),
Bytes.fromHexString("0x03"),
Bytes.fromHexString("0x04"),
],
Bytes.fromHexString("0x10"),
Bytes.fromHexString("0x20"),
Bytes.fromHexString("0xaa"),
Bytes.fromHexString("0xbb"),
);
const event = createTransactEvent(
BigInt.fromI32(1),
BigInt.fromI32(0),
[Bytes.fromHexString("0x1234")],
[ciphertextTuple],
);
handleTransact(event);
});
afterAll(() => {
clearStore();
});
test("RailgunTransact created", () => {
assert.entityCount("RailgunTransact", 1);
});
test("Ciphertext entity created", () => {
assert.entityCount("RailgunTransactCiphertext", 1);
});
test("Ciphertext fields stored correctly", () => {
const id = "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1-ct-0";
assert.fieldEquals("RailgunTransactCiphertext", id, "ciphertext0", "0x01");
assert.fieldEquals("RailgunTransactCiphertext", id, "ciphertext1", "0x02");
assert.fieldEquals("RailgunTransactCiphertext", id, "ciphertext2", "0x03");
assert.fieldEquals("RailgunTransactCiphertext", id, "ciphertext3", "0x04");
assert.fieldEquals("RailgunTransactCiphertext", id, "blindedSenderViewingKey", "0x10");
assert.fieldEquals("RailgunTransactCiphertext", id, "blindedReceiverViewingKey", "0x20");
});
test("Protocol stats updated", () => {
assert.fieldEquals("RailgunProtocolStats", "railgun-protocol-stats", "totalTxCount", "1");
});
test("Operation stats updated (transact)", () => {
assert.fieldEquals("RailgunOperationStats", "railgun-protocol-stats-transact", "totalCount", "1");
});
});