Skip to content

Commit d1834b6

Browse files
author
SeungMin Lee
committed
Remove the score from the Header in the tests
1 parent 7cf0265 commit d1834b6

14 files changed

+11
-91
lines changed

test/src/e2e.long/invalidBlockPropagation.helper.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ async function setup(): Promise<[Header, Block, Header]> {
5858
new H256(block0.transactionsRoot),
5959
new H256(block0.nextValidatorSetHash),
6060
new H256(block0.stateRoot),
61-
new U256(`${block0.score}`),
6261
block0.seal
6362
);
6463
const author1 = Address.fromString(block1.author);
@@ -71,7 +70,6 @@ async function setup(): Promise<[Header, Block, Header]> {
7170
new H256(block1.transactionsRoot),
7271
new H256(block1.nextValidatorSetHash),
7372
new H256(block1.stateRoot),
74-
new U256(2222222222222),
7573
block1.seal
7674
);
7775
const author3 = Address.fromString(block0.author);
@@ -84,7 +82,6 @@ async function setup(): Promise<[Header, Block, Header]> {
8482
new H256(block2.transactionsRoot),
8583
new H256(block2.nextValidatorSetHash),
8684
new H256(block2.stateRoot),
87-
new U256(33333333333333),
8885
block2.seal
8986
);
9087
return [header0, block1, header2];
@@ -120,14 +117,12 @@ async function testBody(
120117
ttransactionRoot?: H256;
121118
tstateRoot?: H256;
122119
tnextValidatorSetHash?: H256;
123-
tscore?: U256;
124120
tseal?: number[][];
125121
}
126122
) {
127123
const {
128124
tnumber,
129125
textraData,
130-
tscore,
131126
tparent,
132127
tauthor,
133128
ttransactionRoot,
@@ -137,7 +132,6 @@ async function testBody(
137132
} = params;
138133

139134
const bestHash = header2.hashing();
140-
const bestScore = header2.getScore();
141135

142136
const author4 = Address.fromString(block1.author);
143137
const header = new Header(
@@ -149,7 +143,6 @@ async function testBody(
149143
new H256(block1.transactionsRoot),
150144
new H256(block1.nextValidatorSetHash),
151145
new H256(block1.stateRoot),
152-
new U256(2222222222222),
153146
block1.seal
154147
);
155148

@@ -174,9 +167,6 @@ async function testBody(
174167
if (tnextValidatorSetHash != null) {
175168
header.setNextValidatorSetHash(tnextValidatorSetHash);
176169
}
177-
if (tscore != null) {
178-
header.setScore(tscore);
179-
}
180170
if (tseal != null) {
181171
header.setSeal(tseal);
182172
}

test/src/e2e.long/invalidBlockPropagation8.test.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

test/src/e2e.long/invalidBlockPropagation9.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ const INVALID_SEAL = [Buffer.from("DEADBEEF")];
2121
const params = {
2222
tseal: INVALID_SEAL
2323
};
24-
createTestSuite(9, "OnChain invalid score seal propagation test", params);
24+
createTestSuite(9, "OnChain invalid seal propagation test", params);

test/src/e2e.long/onChainBlockValid.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ describe("Test onChain block communication", async function() {
7676
new H256(genesisBlock.transactionsRoot),
7777
new H256(genesisBlock.stateRoot),
7878
new H256(genesisBlock.nextValidatorSetHash),
79-
new U256(`${genesisBlock.score}`),
8079
genesisBlock.seal
8180
);
8281
const author2PlatformAddr = Address.fromString(block1.author);
@@ -89,7 +88,6 @@ describe("Test onChain block communication", async function() {
8988
new H256(block1.transactionsRoot),
9089
new H256(block1.stateRoot),
9190
new H256(block1.nextValidatorSetHash),
92-
new U256(2222222222222),
9391
block1.seal
9492
);
9593
const author3PlatformAddr = Address.fromString(block2.author);
@@ -102,7 +100,6 @@ describe("Test onChain block communication", async function() {
102100
new H256(block2.transactionsRoot),
103101
new H256(block2.stateRoot),
104102
new H256(block2.nextValidatorSetHash),
105-
new U256(33333333333333),
106103
block2.seal
107104
);
108105

@@ -137,8 +134,7 @@ describe("Test onChain block communication", async function() {
137134
header2.toEncodeObject()
138135
],
139136
[[], []],
140-
header2.hashing(),
141-
header2.getScore()
137+
header2.hashing()
142138
);
143139

144140
await mock.waitStatusMessage();

test/src/helper/mock/cHeader.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ export class Header {
2929
const stateRoot = new H256(decodedmsg[2].toString("hex"));
3030
const transactionsRoot = new H256(decodedmsg[3].toString("hex"));
3131
const nextValidatorSetHash = new H256(decodedmsg[4].toString("hex"));
32-
const score = decodedmsg[5];
33-
const number = new U256(parseInt(decodedmsg[6].toString("hex"), 16));
34-
const timestamp = new U256(parseInt(decodedmsg[7].toString("hex"), 16));
35-
const extraData = decodedmsg[8];
32+
const number = new U256(parseInt(decodedmsg[5].toString("hex"), 16));
33+
const timestamp = new U256(parseInt(decodedmsg[6].toString("hex"), 16));
34+
const extraData = decodedmsg[7];
3635

3736
// Be careful of the order! Three roots have same types, so mistake on the order will not be catched by typechecker.
3837
const header = new Header(
@@ -44,11 +43,10 @@ export class Header {
4443
transactionsRoot,
4544
stateRoot,
4645
nextValidatorSetHash,
47-
score,
4846
[]
4947
);
5048

51-
for (let i = 9; i < decodedmsg.getLength(); i++) {
49+
for (let i = 8; i < decodedmsg.getLength(); i++) {
5250
header.seal.push(decodedmsg[i]);
5351
}
5452

@@ -62,7 +60,6 @@ export class Header {
6260
private transactionsRoot: H256;
6361
private stateRoot: H256;
6462
private nextValidatorSetHash: H256;
65-
private score: U256;
6663
private seal: number[][];
6764
private hash: null | H256;
6865
private bareHash: null | H256;
@@ -76,7 +73,6 @@ export class Header {
7673
transactionsRoot: H256,
7774
stateRoot: H256,
7875
nextValidatorSetHash: H256,
79-
score: U256,
8076
seal: number[][],
8177
hash?: H256,
8278
bareHash?: H256
@@ -89,7 +85,6 @@ export class Header {
8985
this.transactionsRoot = transactionsRoot;
9086
this.stateRoot = stateRoot;
9187
this.nextValidatorSetHash = nextValidatorSetHash;
92-
this.score = score;
9388
this.seal = seal;
9489
this.hash = hash == null ? this.hashing() : hash;
9590
this.bareHash = bareHash == null ? null : bareHash;
@@ -127,10 +122,6 @@ export class Header {
127122
this.nextValidatorSetHash = root;
128123
}
129124

130-
public setScore(score: U256) {
131-
this.score = score;
132-
}
133-
134125
public setSeal(seal: number[][]) {
135126
this.seal = seal;
136127
}
@@ -143,10 +134,6 @@ export class Header {
143134
return this.bareHash;
144135
}
145136

146-
public getScore(): U256 {
147-
return this.score;
148-
}
149-
150137
public default(): Header {
151138
return new Header(
152139
new H256(
@@ -159,9 +146,6 @@ export class Header {
159146
BLAKE_NULL_RLP,
160147
BLAKE_NULL_RLP,
161148
BLAKE_NULL_RLP,
162-
new U256(
163-
"0000000000000000000000000000000000000000000000000000000000000000"
164-
),
165149
[]
166150
);
167151
}
@@ -173,7 +157,6 @@ export class Header {
173157
this.stateRoot.toEncodeObject(),
174158
this.transactionsRoot.toEncodeObject(),
175159
this.nextValidatorSetHash.toEncodeObject(),
176-
this.score.toEncodeObject(),
177160
this.number.toEncodeObject(),
178161
this.timestamp.toEncodeObject(),
179162
this.extraData

test/src/helper/mock/example/send-block.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ async function sendBlock() {
2020
header2.toEncodeObject()
2121
],
2222
[[], []],
23-
header2.hashing(),
24-
header2.getScore()
23+
header2.hashing()
2524
);
2625

2726
await mock.end();

test/src/helper/mock/index.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ export class Mock {
419419
const nextValidatorSetHash = new H256(
420420
"45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0"
421421
);
422-
const score = new U256(131072);
423422
const seal: any[] = [];
424423
const header = new Header(
425424
parentHash,
@@ -430,7 +429,6 @@ export class Mock {
430429
transactionsRoot,
431430
stateRoot,
432431
nextValidatorSetHash,
433-
score,
434432
seal
435433
);
436434

@@ -452,7 +450,6 @@ export class Mock {
452450
const nextValidatorSetHash = new H256(
453451
"45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0"
454452
);
455-
const score = new U256(999999999999999);
456453
const seal: any[] = [];
457454
const header = new Header(
458455
parentHash,
@@ -463,7 +460,6 @@ export class Mock {
463460
transactionsRoot,
464461
stateRoot,
465462
nextValidatorSetHash,
466-
score,
467463
seal
468464
);
469465

@@ -485,7 +481,6 @@ export class Mock {
485481
const nextValidatorSetHash = new H256(
486482
"45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0"
487483
);
488-
const score = new U256(999999999999999);
489484
const seal: any[] = [];
490485
const header = new Header(
491486
parentHash,
@@ -496,7 +491,6 @@ export class Mock {
496491
transactionsRoot,
497492
stateRoot,
498493
nextValidatorSetHash,
499-
score,
500494
seal
501495
);
502496

@@ -598,17 +592,17 @@ export class Mock {
598592
const block: any = RLP.decode(message.message);
599593
const oldOn: Parameters<typeof digest>[0] = {
600594
step: {
601-
height: readUIntRLP(block[0][6]),
595+
height: readUIntRLP(block[0][5]),
602596
view: message.view,
603597
step: TendermintStep.Propose
604598
},
605599
blockHash: new H256(blake256(RLP.encode(block[0])))
606600
};
607601
if (verifyEd25519(digest(oldOn), signature, pub)) {
608602
const newHeader = [
609-
...block[0].slice(0, 7),
610-
new U64(readUIntRLP(block[0][7]) + 1).toEncodeObject(), // timestamp
611-
...block[0].slice(8)
603+
...block[0].slice(0, 6),
604+
new U64(readUIntRLP(block[0][6]) + 1).toEncodeObject(), // timestamp
605+
...block[0].slice(7)
612606
];
613607
const newDigest = digest({
614608
...oldOn,

test/src/scheme/mempool.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"seal": {
3131
"generic": "0x0"
3232
},
33-
"score": "0x20000",
3433
"author": "tccqyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhhn9p3",
3534
"timestamp": "0x00",
3635
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",

test/src/scheme/solo-block-reward-50.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"seal": {
3838
"generic": "0x0"
3939
},
40-
"score": "0x20000",
4140
"author": "tccqyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhhn9p3",
4241
"timestamp": "0x00",
4342
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",

test/src/scheme/tendermint-dynval.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
]
5555
}
5656
},
57-
"score": "0x20000",
5857
"author": "tccq8zjtcf7d27l55hgthudmhx0g7zd6dw9rg9c77t5",
5958
"timestamp": "0x00",
6059
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",

0 commit comments

Comments
 (0)