Skip to content

Commit 9274e92

Browse files
HoOngEemajecty
authored andcommitted
Remove test code related to reorganization
1 parent 5c90ab2 commit 9274e92

File tree

4 files changed

+4
-398
lines changed

4 files changed

+4
-398
lines changed

test/src/e2e.long/reward2.test.ts

Lines changed: 1 addition & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018-2019 Kodebox, Inc.
1+
// Copyright 2018-2020 Kodebox, Inc.
22
// This file is part of CodeChain.
33
//
44
// This program is free software: you can redistribute it and/or modify
@@ -51,149 +51,6 @@ describe("reward2", function() {
5151
).to.deep.equal(new U64(50));
5252
}).timeout(30_000);
5353

54-
it("alice creates one block and bob creates two blocks in parallel. And then, sync", async function() {
55-
await nodeA.sdk.rpc.devel.startSealing();
56-
expect(
57-
await nodeA.sdk.rpc.chain.getBalance(aliceAddress)
58-
).to.deep.equal(new U64(50));
59-
60-
await nodeB.sdk.rpc.devel.startSealing();
61-
await nodeB.sdk.rpc.devel.startSealing();
62-
expect(await nodeB.sdk.rpc.chain.getBalance(bobAddress)).to.deep.equal(
63-
new U64(100)
64-
);
65-
66-
await nodeA.connect(nodeB);
67-
await nodeA.waitBlockNumberSync(nodeB);
68-
69-
expect(
70-
await nodeA.sdk.rpc.chain.getBalance(aliceAddress)
71-
).to.deep.equal(new U64(0));
72-
expect(await nodeA.sdk.rpc.chain.getBalance(bobAddress)).to.deep.equal(
73-
new U64(100)
74-
);
75-
}).timeout(30_000);
76-
77-
it("A reorganization of block rewards and payments", async function() {
78-
// nodeA creates a block
79-
{
80-
await nodeA.sdk.rpc.devel.startSealing(); // +50 for alice
81-
expect(
82-
await nodeA.sdk.rpc.chain.getBalance(aliceAddress)
83-
).to.deep.equal(new U64(50));
84-
}
85-
86-
// sync and disconnect
87-
{
88-
await nodeB.connect(nodeA);
89-
await nodeB.waitBlockNumberSync(nodeA);
90-
91-
expect(
92-
await nodeB.sdk.rpc.chain.getBalance(aliceAddress)
93-
).to.deep.equal(new U64(50));
94-
95-
await nodeB.disconnect(nodeA);
96-
}
97-
98-
// nodeA creates 2 blocks
99-
{
100-
await nodeA.pay(aliceAddress, 100); // +100 +50 +10*4/10 for alice in nodeA, +10*3/10 for bob
101-
expect(
102-
await nodeA.sdk.rpc.chain.getBalance(aliceAddress)
103-
).to.deep.equal(new U64(50 + 100 + 50 + 4));
104-
expect(
105-
await nodeA.sdk.rpc.chain.getBalance(bobAddress)
106-
).to.deep.equal(new U64(3));
107-
await nodeA.sdk.rpc.chain.sendSignedTransaction(
108-
nodeA.sdk.core
109-
.createPayTransaction({
110-
recipient: bobAddress,
111-
quantity: 5
112-
})
113-
.sign({
114-
secret: aliceSecret,
115-
fee: 10,
116-
seq: 0
117-
})
118-
); // +50 -5 + 10*4/10 -10 for alice, +5 +10*3/10 for bob in nodeA
119-
120-
expect(
121-
await nodeA.sdk.rpc.chain.getBalance(aliceAddress)
122-
).to.deep.equal(new U64(50 + 100 + 50 + 4 + 50 - 5 + 4 - 10));
123-
expect(
124-
await nodeA.sdk.rpc.chain.getBalance(bobAddress)
125-
).to.deep.equal(new U64(3 + 5 + 3));
126-
}
127-
128-
// nodeB creates 3 blocks
129-
{
130-
await nodeB.pay(aliceAddress, 200); // +200 +10*4/10 for alice, +50 +10*3/10 for bob in nodeB
131-
expect(
132-
await nodeB.sdk.rpc.chain.getBalance(aliceAddress)
133-
).to.deep.equal(new U64(50 + 200 + 4));
134-
expect(
135-
await nodeB.sdk.rpc.chain.getBalance(bobAddress)
136-
).to.deep.equal(new U64(50 + 3));
137-
await nodeB.pay(bobAddress, 300); // 10*4/10 for alice, +300 +50 +10*3/10 for bob in nodeB
138-
expect(
139-
await nodeB.sdk.rpc.chain.getBalance(aliceAddress)
140-
).to.deep.equal(new U64(50 + 200 + 4 + 4));
141-
expect(
142-
await nodeB.sdk.rpc.chain.getBalance(bobAddress)
143-
).to.deep.equal(new U64(50 + 3 + 300 + 50 + 3));
144-
await nodeB.sdk.rpc.chain.sendSignedTransaction(
145-
nodeB.sdk.core
146-
.createPayTransaction({
147-
recipient: bobAddress,
148-
quantity: 15
149-
})
150-
.sign({
151-
secret: aliceSecret,
152-
fee: 10,
153-
seq: 0
154-
})
155-
); // -15 -10 +10*4/10 for alice. +50 + 15 + 10*3/10 for bob in nodeB
156-
expect(
157-
await nodeB.sdk.rpc.chain.getBalance(aliceAddress)
158-
).to.deep.equal(new U64(50 + 200 + 4 + 4 - 15 - 10 + 4));
159-
expect(
160-
await nodeB.sdk.rpc.chain.getBalance(bobAddress)
161-
).to.deep.equal(new U64(50 + 3 + 300 + 50 + 3 + 50 + 15 + 3));
162-
}
163-
164-
// sync. nodeA now sees nodeB's state
165-
{
166-
const nodeBBestBlockHash = await nodeB.getBestBlockHash();
167-
expect(await nodeB.getBestBlockNumber()).to.equal(4);
168-
169-
await nodeB.connect(nodeA);
170-
await nodeA.waitBlockNumberSync(nodeB);
171-
expect(await nodeA.getBestBlockHash()).to.deep.equal(
172-
nodeBBestBlockHash
173-
);
174-
175-
expect(
176-
await nodeA.sdk.rpc.chain.getBalance(aliceAddress)
177-
).to.deep.equal(new U64(50 + 200 + 4 + 4 - 15 - 10 + 4));
178-
expect(
179-
await nodeA.sdk.rpc.chain.getBalance(bobAddress)
180-
).to.deep.equal(new U64(50 + 3 + 300 + 50 + 3 + 50 + 15 + 3));
181-
}
182-
183-
// nodeA creates a block
184-
{
185-
await nodeA.pay(aliceAddress, 1000); // +1000 + 50 + 10*4/10 for alice, 10*3/10 for bob
186-
expect(
187-
await nodeA.sdk.rpc.chain.getBalance(aliceAddress)
188-
).to.deep.equal(
189-
new U64(50 + 200 + 4 + 4 - 15 - 10 + 4 + 1000 + 50 + 4)
190-
);
191-
expect(
192-
await nodeA.sdk.rpc.chain.getBalance(bobAddress)
193-
).to.deep.equal(new U64(50 + 3 + 300 + 50 + 3 + 50 + 15 + 3 + 3));
194-
}
195-
}).timeout(120_000);
196-
19754
afterEach(async function() {
19855
if (this.currentTest!.state === "failed") {
19956
nodeA.keepLogs();

test/src/e2e.long/sync2.test.ts

Lines changed: 1 addition & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018-2019 Kodebox, Inc.
1+
// Copyright 2018-2020 Kodebox, Inc.
22
// This file is part of CodeChain.
33
//
44
// This program is free software: you can redistribute it and/or modify
@@ -58,27 +58,6 @@ describe("sync 2 nodes", function() {
5858
await nodeB.sdk.rpc.chain.getTransaction(transaction.hash())
5959
).not.null;
6060
}).timeout(30_000);
61-
62-
describe("A-B diverged", function() {
63-
beforeEach(async function() {
64-
await nodeA.sendPayTx();
65-
await nodeB.sendPayTx();
66-
expect(await nodeA.getBestBlockNumber()).to.equal(
67-
await nodeB.getBestBlockNumber()
68-
);
69-
expect(await nodeA.getBestBlockHash()).to.not.deep.equal(
70-
await nodeB.getBestBlockHash()
71-
);
72-
});
73-
74-
it("It should be synced when nodeA becomes ahead", async function() {
75-
await nodeA.sendPayTx();
76-
await nodeB.waitBlockNumberSync(nodeA);
77-
expect(await nodeA.getBestBlockHash()).to.deep.equal(
78-
await nodeB.getBestBlockHash()
79-
);
80-
}).timeout(10_000);
81-
});
8261
});
8362

8463
describe("nodeA becomes ahead", function() {
@@ -94,104 +73,6 @@ describe("sync 2 nodes", function() {
9473
);
9574
}).timeout(10_000);
9675
});
97-
98-
describe("A-B diverged", function() {
99-
beforeEach(async function() {
100-
await nodeA.sendPayTx();
101-
await nodeB.sendPayTx();
102-
expect(await nodeA.getBestBlockNumber()).to.equal(
103-
await nodeB.getBestBlockNumber()
104-
);
105-
expect(await nodeA.getBestBlockHash()).to.not.deep.equal(
106-
await nodeB.getBestBlockHash()
107-
);
108-
});
109-
110-
describe("nodeA becomes ahead", function() {
111-
beforeEach(async function() {
112-
await nodeA.sendPayTx();
113-
expect(await nodeA.getBestBlockNumber()).to.equal(
114-
(await nodeB.getBestBlockNumber()) + 1
115-
);
116-
});
117-
118-
it("It should be synced when A-B connected", async function() {
119-
await nodeA.connect(nodeB);
120-
await nodeB.waitBlockNumberSync(nodeA);
121-
expect(await nodeA.getBestBlockHash()).to.deep.equal(
122-
await nodeB.getBestBlockHash()
123-
);
124-
}).timeout(30_000);
125-
});
126-
});
127-
128-
describe("A-B diverged with the same transaction", function() {
129-
beforeEach(async function() {
130-
const transactionA = await nodeA.sendPayTx({ fee: 10 });
131-
await wait(1000);
132-
const transactionB = await nodeB.sendPayTx({ fee: 10 });
133-
expect(transactionA.unsigned).to.deep.equal(
134-
transactionB.unsigned
135-
);
136-
expect(await nodeA.getBestBlockNumber()).to.equal(
137-
await nodeB.getBestBlockNumber()
138-
);
139-
expect(await nodeA.getBestBlockHash()).to.not.deep.equal(
140-
await nodeB.getBestBlockHash()
141-
);
142-
});
143-
144-
describe("nodeA becomes ahead", function() {
145-
beforeEach(async function() {
146-
await nodeA.sendPayTx();
147-
expect(await nodeA.getBestBlockNumber()).to.equal(
148-
(await nodeB.getBestBlockNumber()) + 1
149-
);
150-
});
151-
152-
it("It should be synced when A-B connected", async function() {
153-
await nodeA.connect(nodeB);
154-
await nodeB.waitBlockNumberSync(nodeA);
155-
expect(await nodeA.getBestBlockHash()).to.deep.equal(
156-
await nodeB.getBestBlockHash()
157-
);
158-
}).timeout(30_000);
159-
});
160-
});
161-
162-
describe("A-B diverged with the same transaction", function() {
163-
describe("Both transaction success", function() {
164-
beforeEach(async function() {
165-
const recipient = await nodeA.createP2PKHAddress();
166-
await nodeA.mintAsset({ supply: 10, recipient });
167-
await nodeB.mintAsset({ supply: 10, recipient });
168-
expect(await nodeA.getBestBlockNumber()).to.equal(
169-
await nodeB.getBestBlockNumber()
170-
);
171-
expect(await nodeA.getBestBlockHash()).to.not.deep.equal(
172-
await nodeB.getBestBlockHash()
173-
);
174-
});
175-
176-
describe("nodeA becomes ahead", function() {
177-
beforeEach(async function() {
178-
this.timeout(60_000);
179-
await nodeA.sendPayTx();
180-
expect(await nodeA.getBestBlockNumber()).to.equal(
181-
(await nodeB.getBestBlockNumber()) + 1
182-
);
183-
});
184-
185-
it("It should be synced when A-B connected", async function() {
186-
await nodeA.connect(nodeB);
187-
await nodeB.waitBlockNumberSync(nodeA);
188-
expect(await nodeA.getBestBlockHash()).to.deep.equal(
189-
await nodeB.getBestBlockHash()
190-
);
191-
}).timeout(30_000);
192-
});
193-
});
194-
});
19576
});
19677

19778
describe("with no transaction relay", function() {

test/src/e2e.long/sync3.test.ts

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018-2019 Kodebox, Inc.
1+
// Copyright 2018-2020 Kodebox, Inc.
22
// This file is part of CodeChain.
33
//
44
// This program is free software: you can redistribute it and/or modify
@@ -67,39 +67,6 @@ describe("sync 3 nodes", function() {
6767
);
6868
}
6969
}).timeout(15_000 + 10_000 * NUM_NODES);
70-
71-
describe("All diverged by both end nodes", function() {
72-
beforeEach(async function() {
73-
const nodeA = nodes[0];
74-
const nodeB = nodes[NUM_NODES - 1];
75-
await nodeA.sendPayTx();
76-
await nodeB.sendPayTx();
77-
expect(await nodeA.getBestBlockNumber()).to.equal(
78-
await nodeB.getBestBlockNumber()
79-
);
80-
expect(await nodeA.getBestBlockHash()).to.not.deep.equal(
81-
await nodeB.getBestBlockHash()
82-
);
83-
});
84-
85-
it("Every node should be synced to one", async function() {
86-
const waits = [];
87-
for (let i = 1; i < NUM_NODES; i++) {
88-
waits.push(nodes[i].waitBlockNumberSync(nodes[0]));
89-
}
90-
await Promise.all(waits);
91-
}).timeout(15_000 + 10_000 * NUM_NODES);
92-
93-
it("It should be synced when the first node becomes ahead", async function() {
94-
await nodes[0].sendPayTx();
95-
for (let i = 1; i < NUM_NODES; i++) {
96-
await nodes[i].waitBlockNumberSync(nodes[i - 1]);
97-
expect(await nodes[i].getBestBlockHash()).to.deep.equal(
98-
await nodes[0].getBestBlockHash()
99-
);
100-
}
101-
}).timeout(15_000 + 10_000 * NUM_NODES);
102-
});
10370
});
10471

10572
describe("the first node becomes ahead", function() {
@@ -153,39 +120,6 @@ describe("sync 3 nodes", function() {
153120
).to.deep.equal(transaction.blockHash);
154121
}
155122
}).timeout(15_000 + 10_000 * NUM_NODES);
156-
157-
describe("All diverged by two nodes in the opposite", function() {
158-
beforeEach(async function() {
159-
const nodeA = nodes[0];
160-
const nodeB = nodes[numHalf];
161-
await nodeA.sendPayTx();
162-
await nodeB.sendPayTx();
163-
expect(await nodeA.getBestBlockNumber()).to.equal(
164-
await nodeB.getBestBlockNumber()
165-
);
166-
expect(await nodeA.getBestBlockHash()).to.not.deep.equal(
167-
await nodeB.getBestBlockHash()
168-
);
169-
});
170-
171-
it("Every node should be synced", async function() {
172-
const waits = [];
173-
for (let i = 1; i < NUM_NODES; i++) {
174-
waits.push(nodes[i].waitBlockNumberSync(nodes[0]));
175-
}
176-
await Promise.all(waits);
177-
}).timeout(15_000 + 10_000 * NUM_NODES);
178-
179-
it("It should be synced when the first node becomes ahead", async function() {
180-
await nodes[0].sendPayTx();
181-
for (let i = 1; i < NUM_NODES; i++) {
182-
await nodes[i].waitBlockNumberSync(nodes[i - 1]);
183-
expect(await nodes[i].getBestBlockHash()).to.deep.equal(
184-
await nodes[0].getBestBlockHash()
185-
);
186-
}
187-
}).timeout(15_000 + 10_000 * NUM_NODES);
188-
});
189123
}).timeout(NUM_NODES * 60_000);
190124

191125
afterEach(async function() {

0 commit comments

Comments
 (0)