CRYPTO NEWS

"await expect" vs. "expect await" in Chai matchers

What is the correct nesting order of await and expect for Chai matchers?

The following does not work:

await expect(contract.name()).to.equal("MyToken"); // (1)  expect(await contract["transfer(address,uint256)"](wallet.address, 100))         .to.be.revertedWith('Insufficient funds'); // (2)  

Errors thrown are respectively:

(1) AssertionError: expected Promise{…} to equal 'MyToken'  (2) Uncaught RuntimeError: abort(TypeError: transactionCall is not a function). 

The following works:

expect(await contract.name()).to.equal("MyToken"); // (1)  await expect(contract["transfer(address,uint256)"](wallet.address, 100))         .to.be.revertedWith('Insufficient funds'); // (2) 

So the problems seem to be:

(1) expect() does not resolve a Promise, and compares it directly to what is passed into .to.equal() — this seems like an oversight!

(2) However expect() does correctly catch errors, but only if they are thrown uncaught within the Promise.

Error when calling factory.methods.getPair with PancakePair (BSC)

After doublechecking all addresses over and over; I’m still running into this error trying to instantiate a contract for CELT_USDT: Error: Returned values aren’t valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data::Listen

After doublechecking all addresses over and over; I’m still running into this error trying to instantiate a contract for CELT_USDT:

Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.     at ABICoder.decodeParametersWith (C:devsgbotnode_modulesweb3-eth-abilibindex.js:297:15)     at ABICoder.decodeParameters (C:devsgbotnode_modulesweb3-eth-abilibindex.js:284:17)     at Contract._decodeMethodReturn (C:devsgbotnode_modulesweb3-eth-contractlibindex.js:493:22)     at Method.outputFormatter (C:devsgbotnode_modulesweb3-eth-contractlibindex.js:800:42)     at Method.formatOutput (C:devsgbotnode_modulesweb3-core-methodlibindex.js:148:54)     at sendTxCallback (C:devsgbotnode_modulesweb3-core-methodlibindex.js:531:33)     at C:devsgbotnode_modulesweb3-core-requestmanagerlibindex.js:305:9 

My getContractPair function is the following

  getContractPair = async function (factory, address0, address1) {     const pairAddress = await factory.methods.getPair(address0, address1).call()      const contract = new web3.eth.Contract(this.pancakeswapPairAbi,       pairAddress)     const token0 = await contract.methods.token0().call()     contract.addressOrderReversed = token0.toLowerCase() !==       address0.toLowerCase()     return contract   } 

Where:

address0 = CELT's contract address = 0x4f34292f109870d5fdda602bc7e3ae56d520d6e1 address1 = Tether USD (Wormhole) = 0x524bc91dc82d6b90ef29f76a3ecaabafffd490bc pancakeswapPairAbi from: https://bscscan.com/address/0x0ed7e52944161450477ee417de9cd3a859b14fd0#code 

Thanks in advance!

"await expect" vs. "expect await" in Chai matchers

Shopping cart
There are no products in the cart!
Continue shopping
0