Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
test: replace assert.equal with assert.strictEqual in tests (#3508)
Browse files Browse the repository at this point in the history
* refactor(chains/ethereum/address): replace `assert.equal` with `assert.strictEqual`
* refactor(chains/ethereum/ethereum): replace `assert.equal` with `assert.strictEqual`
* refactor(chains/ethereum/options): replace `assert.equal` with `assert.strictEqual`
* refactor(packages/utils): replace `assert.equal` with `assert.strictEqual`
  • Loading branch information
gr7d committed Aug 11, 2022
1 parent df29a09 commit 1592b1d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/chains/ethereum/address/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("@ganache/ethereum-address", () => {
const address = new Address("0x1");
const stringifiedAddress = address.toString();

assert.equal(
assert.strictEqual(
stringifiedAddress,
"0x0000000000000000000000000000000000000001"
);
Expand All @@ -17,14 +17,14 @@ describe("@ganache/ethereum-address", () => {
const address = new Address("0x1");
const stringifiedAddress = address.toString(1);

assert.equal(stringifiedAddress, "0x01");
assert.strictEqual(stringifiedAddress, "0x01");
});

it("should stringify a 20 byte address string", () => {
const address = new Address("0x2104859394604359378433865360947116707876");
const stringifiedAddress = address.toString();

assert.equal(
assert.strictEqual(
stringifiedAddress,
"0x2104859394604359378433865360947116707876"
);
Expand All @@ -33,7 +33,7 @@ describe("@ganache/ethereum-address", () => {
it("should pad an address to 20 bytes when called as static function", () => {
const stringifiedAddress = Address.toString("0x1");

assert.equal(
assert.strictEqual(
stringifiedAddress,
"0x0000000000000000000000000000000000000001"
);
Expand All @@ -54,7 +54,7 @@ describe("@ganache/ethereum-address", () => {
const address = new Address("0x2104859394604359378433865360947116707876");
const stringifiedAddress = address.toString(1);

assert.equal(stringifiedAddress, "0x21");
assert.strictEqual(stringifiedAddress, "0x21");
});

it("should convert a 20 byte address to a buffer", () => {
Expand Down
9 changes: 6 additions & 3 deletions src/chains/ethereum/ethereum/tests/blockchain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ describe("blockchain", async () => {
try {
const blockNumber = block.header.number.toString();
const expectedBlockNumber = startingBlockNumber + i + 1;
assert.equal(blockNumber, `0x${expectedBlockNumber.toString(16)}`);
assert.equal(transactions.length, 1);
assert.strictEqual(
blockNumber,
`0x${expectedBlockNumber.toString(16)}`
);
assert.strictEqual(transactions.length, 1);

const transaction = transactions[0];
assert.equal(
assert.strictEqual(
transaction.hash.toString(),
transactionHashes[i].toString()
);
Expand Down
4 changes: 2 additions & 2 deletions src/chains/ethereum/options/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("EthereumOptionsConfig", () => {
const options = EthereumOptionsConfig.normalize({
wallet: { totalAccounts: 7 }
});
assert.equal(options.wallet.totalAccounts, 7);
assert.strictEqual(options.wallet.totalAccounts, 7);
});
it("throws an error when an option conflict is found", () => {
assert.throws(() => {
Expand All @@ -55,7 +55,7 @@ describe("EthereumOptionsConfig", () => {
it("accepts some legacy input formats", () => {
const seed = "from their voids, cry to the dolphined sea";
const options = EthereumOptionsConfig.normalize({ seed } as Object);
assert.equal(options.wallet.seed, seed);
assert.strictEqual(options.wallet.seed, seed);
});
it("errors if there is a conflict with legacy inputs", () => {
const seed = "I ate three cookies";
Expand Down
8 changes: 4 additions & 4 deletions src/packages/utils/tests/json-rpc-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ describe("json-rpc-data", () => {
"hex"
)}`, () => {
const result = new Data(<Buffer>input).toString();
assert.equal(result, expected);
assert.strictEqual(result, expected);
});
});

it("should truncate to a shorter byteLength", () => {
const result = new Data(
Buffer.from([0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef])
).toString(1);
assert.equal(result, "0x01");
assert.strictEqual(result, "0x01");
});

it("should pad to a longer byteLength", () => {
const result = new Data(Buffer.from([0x01])).toString(10);
assert.equal(result, "0x00000000000000000001");
assert.strictEqual(result, "0x00000000000000000001");
});
});

Expand Down Expand Up @@ -113,7 +113,7 @@ describe("json-rpc-data", () => {
it("should return false for any non-empty buffer", () => {
[Buffer.allocUnsafe(1), Buffer.allocUnsafe(2)].forEach(input => {
const data = new Data(input);
assert.equal(data.isNull(), false);
assert.strictEqual(data.isNull(), false);
});
});
});
Expand Down
21 changes: 13 additions & 8 deletions src/packages/utils/tests/json-rpc-quantity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ const testData = [
0x0123456789abcdef,
Buffer.from([0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef])
],
[Buffer.from([0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]), "0x10000000000000", 0x10000000000000, Buffer.from([ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])]
[
Buffer.from([0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]),
"0x10000000000000",
0x10000000000000,
Buffer.from([0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
]
];

const nullLikeInputs = [null, undefined, Buffer.alloc(0)];
Expand Down Expand Up @@ -70,14 +75,14 @@ describe("json-rpc-quantity", () => {
it("should return 0x0 for a non-empty buffer of 0x00 bytes", () => {
const result = new Quantity(Buffer.alloc(10), true).toString();

assert.equal(result, "0x0");
assert.strictEqual(result, "0x0");
});

it(`should return "0x0" for null-like inputs`, () => {
nullLikeInputs.forEach(input => {
const result = new Quantity(input, false).toString();

assert.equal(result, "0x0");
assert.strictEqual(result, "0x0");
});
});

Expand All @@ -88,7 +93,7 @@ describe("json-rpc-quantity", () => {
[true, false].forEach(nullable => {
const result = new Quantity(input, nullable).toString();

assert.equal(result, expected);
assert.strictEqual(result, expected);
});
});
});
Expand All @@ -106,14 +111,14 @@ describe("json-rpc-quantity", () => {
it("should return null for empty input", () => {
const result = new Quantity(Buffer.alloc(0), true).toNumber();

assert.equal(result, null);
assert.strictEqual(result, null);
});

it("should return 0 for null-like inputs", () => {
nullLikeInputs.forEach(input => {
const result = new Quantity(input, false).toNumber();

assert.equal(result, 0);
assert.strictEqual(result, 0);
});
});

Expand All @@ -124,7 +129,7 @@ describe("json-rpc-quantity", () => {
[true, false].forEach(nullable => {
const result = new Quantity(input, nullable).toNumber();

assert.equal(result, expected);
assert.strictEqual(result, expected);
});
});
});
Expand Down Expand Up @@ -182,7 +187,7 @@ describe("json-rpc-quantity", () => {
[Buffer.alloc(1), Buffer.alloc(2)].forEach(input => {
const quantity = new Quantity(input, nullable);

assert.equal(quantity.isNull(), false);
assert.strictEqual(quantity.isNull(), false);
});
});
});
Expand Down

0 comments on commit 1592b1d

Please sign in to comment.