Skip to content

Commit 6f90ce2

Browse files
committed
Change pay, shard, and regularkey e2e tests
1 parent 90ff2b1 commit 6f90ce2

File tree

3 files changed

+255
-152
lines changed

3 files changed

+255
-152
lines changed

test/src/e2e/pay.test.ts

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,57 @@ describe("Pay", async function() {
2929

3030
it("Allow zero pay", async function() {
3131
const pay = await node.sendPayTx({ quantity: 0 });
32-
expect(await node.sdk.rpc.chain.containsTransaction(pay.hash())).be
33-
.true;
34-
expect(await node.sdk.rpc.chain.getTransaction(pay.hash())).not.null;
32+
expect(
33+
await node.rpc.chain.containsTransaction({
34+
transactionHash: `0x${pay.hash().toString()}`
35+
})
36+
).be.true;
37+
expect(
38+
await node.rpc.chain.getTransaction({
39+
transactionHash: `0x${pay.hash().toString()}`
40+
})
41+
).not.null;
3542
});
3643

3744
it("Allow pay to itself", async function() {
3845
const pay = await node.sendPayTx({
3946
quantity: 100,
4047
recipient: faucetAddress
4148
});
42-
expect(await node.sdk.rpc.chain.containsTransaction(pay.hash())).be
43-
.true;
44-
expect(await node.sdk.rpc.chain.getTransaction(pay.hash())).not.null;
49+
expect(
50+
await node.rpc.chain.containsTransaction({
51+
transactionHash: `0x${pay.hash().toString()}`
52+
})
53+
).be.true;
54+
expect(
55+
await node.rpc.chain.getTransaction({
56+
transactionHash: `0x${pay.hash().toString()}`
57+
})
58+
).not.null;
4559
});
4660

4761
it("Cannot pay to regular key", async function() {
4862
const charge = await node.sendPayTx({
4963
quantity: 100000,
5064
recipient: aliceAddress
5165
});
52-
expect(await node.sdk.rpc.chain.containsTransaction(charge.hash())).be
53-
.true;
54-
expect(await node.sdk.rpc.chain.getTransaction(charge.hash())).not.null;
66+
expect(
67+
await node.rpc.chain.containsTransaction({
68+
transactionHash: `0x${charge.hash().toString()}`
69+
})
70+
).be.true;
71+
expect(
72+
await node.rpc.chain.getTransaction({
73+
transactionHash: `0x${charge.hash().toString()}`
74+
})
75+
).not.null;
5576

5677
const privKey = node.sdk.util.generatePrivateKey();
5778
const pubKey = node.sdk.util.getPublicFromPrivate(privKey);
58-
const aliceSeq = await node.sdk.rpc.chain.getSeq(aliceAddress);
79+
const aliceSeq = (await node.rpc.chain.getSeq({
80+
address: aliceAddress.toString(),
81+
blockNumber: null
82+
}))!;
5983
await node.setRegularKey(pubKey, {
6084
seq: aliceSeq,
6185
secret: aliceSecret
@@ -64,10 +88,13 @@ describe("Pay", async function() {
6488
networkId: node.sdk.networkId
6589
});
6690

67-
const seq = await node.sdk.rpc.chain.getSeq(faucetAddress);
91+
const seq = (await node.rpc.chain.getSeq({
92+
address: faucetAddress.toString(),
93+
blockNumber: null
94+
}))!;
6895
const blockNumber = await node.getBestBlockNumber();
6996

70-
await node.sdk.rpc.devel.stopSealing();
97+
await node.rpc.devel!.stopSealing();
7198

7299
const pay = await node.sendPayTx({ quantity: 0, seq });
73100
const fail = await node.sendPayTx({
@@ -76,16 +103,30 @@ describe("Pay", async function() {
76103
seq: seq + 1
77104
});
78105

79-
await node.sdk.rpc.devel.startSealing();
106+
await node.rpc.devel!.startSealing();
80107
await node.waitBlockNumber(blockNumber + 1);
81108

82-
expect(await node.sdk.rpc.chain.containsTransaction(pay.hash())).be
83-
.true;
84-
expect(await node.sdk.rpc.chain.getTransaction(pay.hash())).not.null;
109+
expect(
110+
await node.rpc.chain.containsTransaction({
111+
transactionHash: `0x${charge.hash().toString()}`
112+
})
113+
).be.true;
114+
expect(
115+
await node.rpc.chain.getTransaction({
116+
transactionHash: `0x${pay.hash().toString()}`
117+
})
118+
).not.null;
85119

86-
expect(await node.sdk.rpc.chain.containsTransaction(fail.hash())).be
87-
.false;
88-
expect(await node.sdk.rpc.chain.getTransaction(fail.hash())).null;
120+
expect(
121+
await node.rpc.chain.containsTransaction({
122+
transactionHash: `0x${fail.hash().toString()}`
123+
})
124+
).be.false;
125+
expect(
126+
await node.rpc.chain.getTransaction({
127+
transactionHash: `0x${fail.hash().toString()}`
128+
})
129+
).null;
89130
expect(await node.sdk.rpc.chain.getErrorHint(fail.hash())).not.null;
90131
});
91132

test/src/e2e/regularkey.test.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,15 @@ describe("solo - 1 node", function() {
8080
});
8181

8282
it("Try to use the master key instead of the regular key", async function() {
83-
const seq = await node.sdk.rpc.chain.getSeq(faucetAddress);
84-
const blockNumber = await node.sdk.rpc.chain.getBestBlockNumber();
85-
await node.sdk.rpc.devel.stopSealing();
83+
const seq = (await node.rpc.chain.getSeq({
84+
address: faucetAddress.toString(),
85+
blockNumber: null
86+
}))!;
87+
const blockNumber = await node.rpc.chain.getBestBlockNumber();
88+
await node.rpc.devel!.stopSealing();
8689
const hash = await node.setRegularKey(pubKey, { seq });
8790
const tx = await node.sendPayTx({ seq: seq + 1 });
88-
await node.sdk.rpc.devel.startSealing();
91+
await node.rpc.devel!.startSealing();
8992
await node.waitBlockNumber(blockNumber + 1);
9093

9194
expect(await node.sdk.rpc.chain.getErrorHint(hash)).be.null;
@@ -99,16 +102,19 @@ describe("solo - 1 node", function() {
99102
{ networkId: "tc" }
100103
).toString();
101104

102-
await node.sdk.rpc.devel.stopSealing();
103-
const blockNumber = await node.sdk.rpc.chain.getBestBlockNumber();
104-
const seq = await node.sdk.rpc.chain.getSeq(faucetAddress);
105+
await node.rpc.devel!.stopSealing();
106+
const blockNumber = await node.rpc.chain.getBestBlockNumber();
107+
const seq = (await node.rpc.chain.getSeq({
108+
address: faucetAddress.toString(),
109+
blockNumber: null
110+
}))!;
105111
const tx1 = await node.sendPayTx({
106112
quantity: 5,
107113
recipient: address,
108114
seq
109115
});
110116
const hash2 = await node.setRegularKey(pubKey, { seq: seq + 1 });
111-
await node.sdk.rpc.devel.startSealing();
117+
await node.rpc.devel!.startSealing();
112118
await node.waitBlockNumber(blockNumber + 1);
113119

114120
const block = (await node.sdk.rpc.chain.getBlock(blockNumber + 1))!;
@@ -127,19 +133,22 @@ describe("solo - 1 node", function() {
127133
).toString();
128134

129135
await node.sendPayTx({ quantity: 100, recipient: address });
130-
const seq = await node.sdk.rpc.chain.getSeq(address);
136+
const seq = (await node.rpc.chain.getSeq({
137+
address: address.toString(),
138+
blockNumber: null
139+
}))!;
131140

132141
const blockNumber = await node.sdk.rpc.chain.getBestBlockNumber();
133142

134-
await node.sdk.rpc.devel.stopSealing();
143+
await node.rpc.devel!.stopSealing();
135144
const hash1 = await node.setRegularKey(pubKey, {
136145
seq,
137146
secret: newPrivKey
138147
});
139148
const hash2 = await node.setRegularKey(pubKey, {
140149
seq: seq + 1
141150
});
142-
await node.sdk.rpc.devel.startSealing();
151+
await node.rpc.devel!.startSealing();
143152

144153
await node.waitBlockNumber(blockNumber);
145154

0 commit comments

Comments
 (0)