Skip to content

Commit 7292d1e

Browse files
Joonmo Yangforiequal0
authored andcommitted
Fix the command for formatting the test scripts
1 parent 836d661 commit 7292d1e

File tree

11 files changed

+561
-239
lines changed

11 files changed

+561
-239
lines changed

test/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"start-dyn-val-release": "cargo build --release && NODE_ENV=production mocha -r ts-node/register --timeout 10000 src/e2e.dynval/*.test.ts",
2121
"tendermint-test-local": "cargo build --release && NODE_ENV=production ts-node src/tendermint.test/local.ts",
2222
"tendermint-test-remote": "NODE_ENV=production ts-node src/tendermint.test/remote.ts",
23-
"lint": "tslint -p . && prettier 'src/*/**.{ts, json}' -l",
24-
"fmt": "tslint -p . --fix && prettier 'src/*/**.{ts, json}' --write"
23+
"lint": "tslint -p . && prettier 'src/**/*.{ts, json}' -l",
24+
"fmt": "tslint -p . --fix && prettier 'src/**/*.{ts, json}' --write"
2525
},
2626
"devDependencies": {
2727
"@types/chai": "^4.1.7",

test/src/helper/mock/blockSyncMessage.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ interface IResponse {
5757
}
5858

5959
export class BlockSyncMessage {
60-
6160
public static fromBytes(bytes: Buffer): BlockSyncMessage {
6261
const decodedmsg = RLP.decode(bytes);
63-
const msgId = decodedmsg[0].length === 0 ? 0 : decodedmsg[0].readUIntBE(0, 1);
62+
const msgId =
63+
decodedmsg[0].length === 0 ? 0 : decodedmsg[0].readUIntBE(0, 1);
6464
if (msgId === MessageType.MESSAGE_ID_STATUS) {
6565
Emitter.emit("status");
6666
const msg = decodedmsg[1];
@@ -74,7 +74,10 @@ export class BlockSyncMessage {
7474
genesisHash
7575
});
7676
} else {
77-
const id = decodedmsg[1].length === 0 ? new U256(0) : new U256(parseInt(decodedmsg[1].toString("hex"), 16));
77+
const id =
78+
decodedmsg[1].length === 0
79+
? new U256(0)
80+
: new U256(parseInt(decodedmsg[1].toString("hex"), 16));
7881
const msg = decodedmsg[2];
7982
switch (msgId) {
8083
case MessageType.MESSAGE_ID_GET_HEADERS:
@@ -173,14 +176,23 @@ interface IStateChunkq {
173176
}
174177

175178
export class RequestMessage {
176-
public static decode(protocol: MessageType, bytes: Array<any>): RequestMessage {
179+
public static decode(
180+
protocol: MessageType,
181+
bytes: Array<any>
182+
): RequestMessage {
177183
switch (protocol) {
178184
case MessageType.MESSAGE_ID_GET_HEADERS: {
179185
Emitter.emit("headerrequest");
180186
return new RequestMessage({
181187
type: "headers",
182-
startNumber: bytes[0].length === 0 ? new U256(0) : new U256(parseInt(bytes[0].toString("hex"), 16)),
183-
maxCount: bytes[1].length === 0 ? new U256(0) : new U256(parseInt(bytes[1].toString("hex"), 16))
188+
startNumber:
189+
bytes[0].length === 0
190+
? new U256(0)
191+
: new U256(parseInt(bytes[0].toString("hex"), 16)),
192+
maxCount:
193+
bytes[1].length === 0
194+
? new U256(0)
195+
: new U256(parseInt(bytes[1].toString("hex"), 16))
184196
});
185197
}
186198
case MessageType.MESSAGE_ID_GET_BODIES: {
@@ -233,7 +245,10 @@ export class RequestMessage {
233245
public toEncodeObject(): Array<any> {
234246
switch (this.body.type) {
235247
case "headers": {
236-
return [this.body.startNumber.toEncodeObject(), this.body.maxCount.toEncodeObject()];
248+
return [
249+
this.body.startNumber.toEncodeObject(),
250+
this.body.maxCount.toEncodeObject()
251+
];
237252
}
238253
case "bodies": {
239254
return this.body.data.map(hash => hash.toEncodeObject());
@@ -277,8 +292,10 @@ interface IStateChunks {
277292
}
278293

279294
export class ResponseMessage {
280-
281-
public static decode(protocol: MessageType, bytes: Array<any>): ResponseMessage {
295+
public static decode(
296+
protocol: MessageType,
297+
bytes: Array<any>
298+
): ResponseMessage {
282299
switch (protocol) {
283300
case MessageType.MESSAGE_ID_HEADERS: {
284301
Emitter.emit("headerresponse");

test/src/helper/mock/cHeader.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ import { H160, H256, U256 } from "codechain-primitives";
1717
import { blake256 } from "codechain-sdk/lib/utils";
1818

1919
const RLP = require("rlp");
20-
const BLAKE_NULL_RLP: H256 = new H256("45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0");
20+
const BLAKE_NULL_RLP: H256 = new H256(
21+
"45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0"
22+
);
2123

2224
export class Header {
23-
2425
public static fromBytes(bytes: Buffer): Header {
2526
const decodedmsg = RLP.decode(bytes);
2627
const parentHash = new H256(decodedmsg[0].toString("hex"));
@@ -138,14 +139,18 @@ export class Header {
138139

139140
public default(): Header {
140141
return new Header(
141-
new H256("0000000000000000000000000000000000000000000000000000000000000000"),
142+
new H256(
143+
"0000000000000000000000000000000000000000000000000000000000000000"
144+
),
142145
new U256(0),
143146
new U256(0),
144147
new H160("0000000000000000000000000000000000000000"),
145148
Buffer.alloc(0),
146149
BLAKE_NULL_RLP,
147150
BLAKE_NULL_RLP,
148-
new U256("0000000000000000000000000000000000000000000000000000000000000000"),
151+
new U256(
152+
"0000000000000000000000000000000000000000000000000000000000000000"
153+
),
149154
[]
150155
);
151156
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ async function sendBlock() {
1414
const header2 = mock.soloBlock2(header1.hashing());
1515

1616
await mock.sendEncodedBlock(
17-
[header.toEncodeObject(), header1.toEncodeObject(), header2.toEncodeObject()],
17+
[
18+
header.toEncodeObject(),
19+
header1.toEncodeObject(),
20+
header2.toEncodeObject()
21+
],
1822
[[], []],
1923
header2.hashing(),
2024
header2.getScore()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ async function sendTransaction() {
1212
networkId: process.env.CODECHAIN_NETWORK_ID || "tc"
1313
});
1414
const ACCOUNT_SECRET =
15-
process.env.ACCOUNT_SECRET || "ede1d4ccb4ec9a8bbbae9a13db3f4a7b56ea04189be86ac3a6a439d9a0a1addd";
15+
process.env.ACCOUNT_SECRET ||
16+
"ede1d4ccb4ec9a8bbbae9a13db3f4a7b56ea04189be86ac3a6a439d9a0a1addd";
1617
const unsigned = sdk.core.createPayTransaction({
1718
recipient: "tccqruq09sfgax77nj4gukjcuq69uzeyv0jcs7vzngg",
1819
amount: 10000

0 commit comments

Comments
 (0)