Last active
May 1, 2023 08:35
-
-
Save HarryR/ec79308a529f6688abc4c4663f9e7fbb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pnpm hardhat --network sapphire_local test tests/hardhat/RandomStorage.test.ts | |
RandomStorage | |
9 ... | |
9 ... | |
10 ... | |
10 ... | |
11 ... | |
11 ... | |
12 ... | |
12 ... | |
13 ... | |
13 ... | |
14 ... | |
1) Goes brrrr | |
0 passing (52s) | |
1 failing | |
1) RandomStorage | |
Goes brrrr: | |
Error: transaction failed [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (transactionHash="0xc494227595e3c47fda3c682a655309847089c6c1cb1e3783b180bd8d10062c40", transaction={"hash":"0xc494227595e3c47fda3c682a655309847089c6c1cb1e3783b180bd8d10062c40","type":0,"accessList":null,"blockHash":"0x8e0bf468b5d43cd6ccf6e1d82d449db739595bb667b2f7cf64a01766a98a16db","blockNumber":2670,"transactionIndex":0,"confirmations":1,"from":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266","gasPrice":{"type":"BigNumber","hex":"0x174876e800"},"maxPriorityFeePerGas":{"type":"BigNumber","hex":"0x174876e800"},"maxFeePerGas":{"type":"BigNumber","hex":"0x174876e800"},"gasLimit":{"type":"BigNumber","hex":"0x989680"},"to":"0xE3011A37A904aB90C8881a99BD1F6E21401f1522","value":{"type":"BigNumber","hex":"0x00"},"nonce":134,"data":"0xa264626f6479a362706b5820f40f3a0d39379ca16c35ab68d7e54c63128d953648a22e08946ae504443db1186464617461589cfebfc7b181ab3e12bbc62c8982db3f847b47461de5cfd94a6de6f70454d92d18f1fef060572161330715eaba3a383d963726d9b0183c0801c7848788630ecfd92c526db786e97cdeea8b490daa935576efd1cf28cc0c53ef4347a57c88f8565a50aba06416673e6e85c27fcb313eef119aaa24150960e03d5d25524bb48a2dfbb421d3eba515184df1408a97ecd81f145bb2856250e0ecf1bd07f16a656e6f6e63654fb92e1f757173614bef458ee048be9f66666f726d617401","r":"0x13ca62379ae46484b99dece4f369c93c75814f8e98eb171d0d1e740d7ca0d766","s":"0x4e87cbdff8b5905b1c336bd35ce48c933684953707523311d16a2df79e154d6c","v":46622,"creates":null,"chainId":23293}, receipt={"to":"0xE3011A37A904aB90C8881a99BD1F6E21401f1522","from":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266","contractAddress":null,"transactionIndex":0,"gasUsed":{"type":"BigNumber","hex":"0x055e"},"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","blockHash":"0x8e0bf468b5d43cd6ccf6e1d82d449db739595bb667b2f7cf64a01766a98a16db","transactionHash":"0xc494227595e3c47fda3c682a655309847089c6c1cb1e3783b180bd8d10062c40","logs":[],"blockNumber":2670,"confirmations":1,"cumulativeGasUsed":{"type":"BigNumber","hex":"0x055e"},"status":0,"type":0,"byzantium":true}, code=CALL_EXCEPTION, version=providers/5.7.2) | |
at Logger.makeError (node_modules/.pnpm/@[email protected]/node_modules/@ethersproject/logger/src.ts/index.ts:269:28) | |
at Logger.throwError (node_modules/.pnpm/@[email protected]/node_modules/@ethersproject/logger/src.ts/index.ts:281:20) | |
at EthersProviderWrapper.<anonymous> (node_modules/.pnpm/@[email protected]/node_modules/@ethersproject/providers/src.ts/base-provider.ts:1549:24) | |
at step (node_modules/.pnpm/@[email protected]/node_modules/@ethersproject/providers/lib/base-provider.js:48:23) | |
at Object.next (node_modules/.pnpm/@[email protected]/node_modules/@ethersproject/providers/lib/base-provider.js:29:53) | |
at fulfilled (node_modules/.pnpm/@[email protected]/node_modules/@ethersproject/providers/lib/base-provider.js:20:58) | |
at processTicksAndRejections (node:internal/process/task_queues:95:5) | |
$ pnpm hardhat --network sapphire_local test tests/hardhat/RandomStorage.test.ts | |
RandomStorage | |
9 ... | |
9 ... | |
10 ... | |
10 ... | |
11 ... | |
11 ... | |
12 ... | |
12 ... | |
1) Goes brrrr | |
0 passing (40s) | |
1 failing | |
1) RandomStorage | |
Goes brrrr: | |
Error: transaction failed [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (transactionHash="0x0ec90a591c9b4e4c8b85d77deb30a6ab9312381cc9360a7837fdaa86eea4ceb7", transaction={"hash":"0x0ec90a591c9b4e4c8b85d77deb30a6ab9312381cc9360a7837fdaa86eea4ceb7","type":0,"accessList":null,"blockHash":"0x46f9a224829317b2ded0836550cdfcb50ce497b4efc1fb49c767c69e0ffdeede","blockNumber":2654,"transactionIndex":0,"confirmations":1,"from":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266","gasPrice":{"type":"BigNumber","hex":"0x174876e800"},"maxPriorityFeePerGas":{"type":"BigNumber","hex":"0x174876e800"},"maxFeePerGas":{"type":"BigNumber","hex":"0x174876e800"},"gasLimit":{"type":"BigNumber","hex":"0x989680"},"to":"0x22753E4264FDDc6181dc7cce468904A80a363E44","value":{"type":"BigNumber","hex":"0x00"},"nonce":121,"data":"0xa264626f6479a362706b58203c1ed421a36aee7f0f030bfa93a4ffa256c2b543a55843de67dd68b71e927731646461746159019d04028741be2005ab24d8e53f28c1e4c370633bd2aea350871bd8bc030963841fb50352014adb7c051de7cb29f54adad63a38c5de060bfa277d777cc7e98e8a8a2fcd2aa9791348bab25b1077be793638a582ca908c59f3c9ba2080dd4fd761e3459bda6c67706af8cdb14b3fc7da47c597af5f176fb289ee418bb52e49e9c8391b6c56b51541b4b9bef371741117249bd0729fdf9dfb5325efe8889ef6166728e92a741419312ef57bb386d15622eeb1ab77940a4a153b65e56cc45e9cea51a60476589683027c8550d649372f6725da996eb45707739c37e1309543690fb94e3770f70f00128d167caa13c9370e3515567c2da12a0d6e2733866daff7d1b1667db14457eee39baa642e91c3faf68eaab45f9e3bc80cdb8e14c65044f9518dd960eef3bf882d8fb208b4c5760286ecc4da1415fb4f3b9e93127c561b4fc6041e9f09770f1efc7aff15342cf5a4974cfa9efe15c360b4793387cb2c87686fb8716426c3bb2122a117bde056eb47ae532e1f0f1fbb0fab4138809d546d87a01da5ff090dc423f6e5296ab888f01366b7580b267511c9d21e19243e0fc246656e6f6e63654f31f5360cca202739143db58deef7cc66666f726d617401","r":"0x67de84ca2c1710f47dd5481fb7603cee0332386a23055fa6447eb2a8de2ff49c","s":"0x1e91e270aaef4544ca45a669714eb1a5223d674a3477bebd99d00c341165ea35","v":46621,"creates":null,"chainId":23293}, receipt={"to":"0x22753E4264FDDc6181dc7cce468904A80a363E44","from":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266","contractAddress":null,"transactionIndex":0,"gasUsed":{"type":"BigNumber","hex":"0x0660"},"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","blockHash":"0x46f9a224829317b2ded0836550cdfcb50ce497b4efc1fb49c767c69e0ffdeede","transactionHash":"0x0ec90a591c9b4e4c8b85d77deb30a6ab9312381cc9360a7837fdaa86eea4ceb7","logs":[],"blockNumber":2654,"confirmations":1,"cumulativeGasUsed":{"type":"BigNumber","hex":"0x0660"},"status":0,"type":0,"byzantium":true}, code=CALL_EXCEPTION, version=providers/5.7.2) | |
at Logger.makeError (node_modules/.pnpm/@[email protected]/node_modules/@ethersproject/logger/src.ts/index.ts:269:28) | |
at Logger.throwError (node_modules/.pnpm/@[email protected]/node_modules/@ethersproject/logger/src.ts/index.ts:281:20) | |
at EthersProviderWrapper.<anonymous> (node_modules/.pnpm/@[email protected]/node_modules/@ethersproject/providers/src.ts/base-provider.ts:1549:24) | |
at step (node_modules/.pnpm/@[email protected]/node_modules/@ethersproject/providers/lib/base-provider.js:48:23) | |
at Object.next (node_modules/.pnpm/@[email protected]/node_modules/@ethersproject/providers/lib/base-provider.js:29:53) | |
at fulfilled (node_modules/.pnpm/@[email protected]/node_modules/@ethersproject/providers/lib/base-provider.js:20:58) | |
at processTicksAndRejections (node:internal/process/task_queues:95:5) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
contract RandomStorage { | |
mapping(bytes32 => bytes32) internal data; | |
event ReadEvent(bytes32 k, bytes32 v); | |
constructor() {} | |
function write(bytes32[] calldata x, bytes32[] calldata y) | |
public | |
{ | |
for( uint i = 0; i < x.length; i++ ) { | |
data[x[i]] = y[i]; | |
} | |
} | |
function read(bytes32[] calldata x) | |
public | |
{ | |
for( uint i = 0; i < x.length; i++ ) { | |
emit ReadEvent(x[i], data[x[i]]); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expect } from "chai"; | |
import { solidityKeccak256 } from "ethers/lib/utils"; | |
import * as hre from "hardhat"; | |
const ethers = hre.ethers; | |
describe('RandomStorage', () => { | |
async function deployFixture() { | |
const RandomStorage = await ethers.getContractFactory('RandomStorage'); | |
const rs = await RandomStorage.deploy(); | |
return { RandomStorage, rs }; | |
} | |
it('Goes brrrr', async () => { | |
const { rs } = await deployFixture(); | |
const blah: [string,string][] = []; | |
for( let i = 0; i < 100; i++ ) { | |
const d = solidityKeccak256(["uint"], [i]); | |
const e = solidityKeccak256(["bytes32"], [d]); | |
blah.push([d, e]); | |
if( blah.length < 10 ) { | |
continue; | |
} | |
const w = blah.slice(-5, -1); | |
const r = blah.slice(-4, -2); | |
const p1 = await rs.write(w.map(_=>_[0]), w.map(_=>_[1])); | |
const p2 = await p1.wait(); | |
console.log(i, '...'); | |
const p3 = await rs.read(r.map(_=>_[0])); | |
const p4 = await p3.wait(); | |
console.log(i, '...'); | |
if( ! p4.events ) throw Error('Expected events!') | |
let j = 0; | |
for( const e of p4.events ) { | |
expect(e.args?.k).to.be.equal(r[j][0]); | |
expect(e.args?.v).to.be.equal(r[j][1]); | |
j += 1; | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment