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

Commit f381fbb

Browse files
committed
🧪 Fix few failing tests"
1 parent 55bdf4c commit f381fbb

File tree

8 files changed

+21
-25
lines changed

8 files changed

+21
-25
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"packages/*/package.json": "node ./scripts/check-truffle-namespace-dependency-versions.js"
4545
},
4646
"resolutions": {
47-
"web3-core": "^4.0.0-alpha.0"
47+
"web3-core": "^4.0.0-alpha.0",
48+
"web3-net": "4.0.0-alpha.0"
4849
}
4950
}

packages/contract-tests/test/abiV2.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ describe("ABIEncoderV2", function () {
3535
addUserReceipt = receipt;
3636
});
3737

38-
it.only("should allow structs as transaction arguments", async function () {
38+
it("should allow structs as transaction arguments", async function () {
3939
assert.strictEqual(
4040
addUserReceipt.status,
41-
true,
41+
BigInt(1),
4242
"addUser transaction should have succeeded."
4343
);
4444
});
@@ -64,8 +64,9 @@ describe("ABIEncoderV2", function () {
6464
);
6565
});
6666

67-
it("should be capable of returning structs from calls", async function () {
67+
it.only("should be capable of returning structs from calls", async function () {
6868
const returnedUser = await userDirectory.user(user.addr);
69+
console.log(returnedUser);
6970

7071
// can't just do assert.deepStrictEqual(returnedUser, user) because
7172
// the decoded struct is actually a tuple, and to emulate that it's

packages/contract/lib/contract/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if (typeof Web3 === "object" && Object.keys(Web3).length === 0) {
4444
var isConstant =
4545
["pure", "view"].includes(item.stateMutability) || item.constant; // new form // deprecated case
4646

47-
var signature = webUtils._jsonInterfaceMethodToString(item);
47+
var signature = webUtils.jsonInterfaceMethodToString(item);
4848

4949
var method = function (constant, web3Method) {
5050
var fn;

packages/contract/lib/execute.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ const execute = {
4343
const defaultGas = utils.bigNumberify(Math.floor(blockLimit / 2));
4444
accept(defaultGas.toHexString());
4545
} else {
46-
console.log({ gas, blockLimit });
4746
const limit = utils.bigNumberify(blockLimit);
4847
// if we did get a numerical gas estimate from interfaceAdapter, we
4948
// multiply that estimate by the gasMultiplier to help ensure we
@@ -59,7 +58,6 @@ const execute = {
5958
}
6059
})
6160
.catch(error => {
62-
console.log({ error });
6361
//HACK: Frankenstein together an error in a destructive fashion!!
6462
debug("error: %O", error);
6563
const reason = Reason._extract({ error }, web3);
@@ -202,7 +200,6 @@ const execute = {
202200

203201
return function () {
204202
const promiEvent = new PromiEvent(false, constructor.debugger);
205-
206203
execute
207204
.prepareCall(constructor, methodABI, arguments)
208205
.then(async ({ args, params, network }) => {
@@ -301,10 +298,8 @@ const execute = {
301298
});
302299

303300
deferred = execute.sendTransaction(web3, params, promiEvent, context); //the crazy things we do for stacktracing...
304-
console.log({ deferred });
305301
try {
306302
const receipt = await deferred;
307-
console.log({ receipt });
308303
if (receipt.status !== undefined && !receipt.status) {
309304
const reason = await Reason.get(params, web3);
310305

packages/contract/lib/handlers.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const handlers = {
6262
error: function (context, error) {
6363
if (!handlers.ignoreTimeoutError(context, error)) {
6464
context.promiEvent.emit("error", error);
65-
this.removeListener("error", handlers.error);
65+
this.off("error", handlers.error);
6666
}
6767
},
6868

@@ -73,18 +73,17 @@ const handlers = {
7373
* @param {String} hash transaction hash
7474
*/
7575
hash: function (context, hash) {
76-
console.log("%%%%% transactionHash", hash);
7776
context.transactionHash = hash;
7877
context.promiEvent.eventEmitter.emit("transactionHash", hash);
79-
this.removeListener("transactionHash", handlers.hash);
78+
this.off("transactionHash", handlers.hash);
8079
},
8180

8281
confirmation: function (context, number, receipt) {
8382
context.promiEvent.eventEmitter.emit("confirmation", number, receipt);
8483

8584
// Per web3: initial confirmation index is 0
8685
if (number === handlers.maxConfirmations + 1) {
87-
this.removeListener("confirmation", handlers.confirmation);
86+
this.off("confirmation", handlers.confirmation);
8887
}
8988
},
9089

@@ -95,7 +94,6 @@ const handlers = {
9594
* @param {Object} receipt transaction receipt
9695
*/
9796
receipt: async function (context, receipt) {
98-
console.log("%%%%% receipt", receipt);
9997
// keep around the raw (not decoded) logs in the raw logs field as a
10098
// stopgap until we can get the ABI for all events, not just the current
10199
// contract
@@ -146,8 +144,8 @@ const handlers = {
146144

147145
//HACK: adding this conditional for when the handler is invoked
148146
//manually during stacktracing
149-
if (this.removeListener) {
150-
this.removeListener("receipt", handlers.receipt);
147+
if (this.off) {
148+
this.off("receipt", handlers.receipt);
151149
}
152150
}
153151
};

packages/contract/lib/utils/index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const debug = require("debug")("contract:utils");
2-
const web3Utils = require("web3-utils");
2+
const BN = require("bn.js");
33
const { bigNumberify } = require("ethers/utils/bignumber");
44
const abi = require("web3-eth-abi");
55
const BlockchainUtils = require("@truffle/blockchain-utils");
@@ -30,11 +30,7 @@ const Utils = {
3030
is_big_number(val) {
3131
if (typeof val !== "object") return false;
3232

33-
//NOTE: For some reason, contrary to the docs,
34-
//web3Utils.isBigNumber returns true not only for
35-
//bignumber.js BigNumbers, but also for ethers BigNumbers,
36-
//even though these are totally different things.
37-
return web3Utils.isBN(val) || web3Utils.isBigNumber(val);
33+
return BN.isBN(val);
3834
},
3935

4036
isTxParams(val) {
@@ -209,12 +205,13 @@ const Utils = {
209205
const ethersBN = bigNumberify(stringValue);
210206
converted.push(ethersBN);
211207
}
212-
if (BigInt.isBigInt(item)) {
208+
if (typeof item === "bigint") {
213209
converted.push(bigNumberify(item.toString()));
214210
} else {
215211
converted.push(item);
216212
}
217213
});
214+
218215
return converted;
219216
},
220217

packages/dashboard-message-bus-e2e-test/test/DashboardServer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe("DashboardServer", () => {
9595
const response = await signer.sendTransaction({
9696
from: accounts[0],
9797
to: accounts[1],
98-
value: utils.parseEther("0.1")
98+
value: utils.parseEther("0.1").toHexString()
9999
});
100100

101101
expect(response).toHaveProperty("hash");

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29546,6 +29546,7 @@ web3-eth@^4.0.0-alpha.1:
2954629546
web3-utils "^4.0.0-alpha.1"
2954729547
web3-validator "^0.1.0-alpha.0"
2954829548

29549+
<<<<<<< HEAD
2954929550
<<<<<<< HEAD
2955029551
<<<<<<< HEAD
2955129552
@@ -29573,6 +29574,9 @@ [email protected]:
2957329574
>>>>>>> 29671cc03 (:art: Fix the issues raised after merging base branch)
2957429575

2957529576
web3-net@^4.0.0-alpha.0:
29577+
=======
29578+
[email protected], [email protected], web3-net@^4.0.0-alpha.0:
29579+
>>>>>>> fa87809d7 (:test_tube: Fix few failing tests")
2957629580
version "4.0.0-alpha.0"
2957729581
resolved "http://localhost:4873/web3-net/-/web3-net-4.0.0-alpha.0.tgz#c7c939f9ad4be0b1f854640d5c9e8469c88af4dd"
2957829582
integrity sha512-K3+Wp8ZYOJeKZ4THcBzCPnCKVdKES6IQYLQz6nBEqJBt+gjax407dfl8B6uMLFL3PSxLg1pS7TwSAAevUryRLw==

0 commit comments

Comments
 (0)