From bd1f5e6237109ad578605bb51d33bcbdeaafaa56 Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Tue, 30 Apr 2024 19:34:22 +0200 Subject: [PATCH 01/18] WIP: handle promise result --- crates/edr_napi/src/call_override.rs | 25 +++++++++++++++---------- crates/edr_napi/src/provider.rs | 6 ++++-- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/crates/edr_napi/src/call_override.rs b/crates/edr_napi/src/call_override.rs index 0544b0bf4..ebf09afd5 100644 --- a/crates/edr_napi/src/call_override.rs +++ b/crates/edr_napi/src/call_override.rs @@ -2,10 +2,11 @@ use std::sync::mpsc::channel; use edr_eth::{Address, Bytes}; use napi::{ - bindgen_prelude::Buffer, + bindgen_prelude::{Buffer, Promise}, threadsafe_function::{ ErrorStrategy, ThreadSafeCallContext, ThreadsafeFunction, ThreadsafeFunctionCallMode, }, + tokio::runtime, Env, JsFunction, Status, }; use napi_derive::napi; @@ -41,10 +42,11 @@ struct CallOverrideCall { #[derive(Clone)] pub struct CallOverrideCallback { call_override_callback_fn: ThreadsafeFunction, + runtime: runtime::Handle, } impl CallOverrideCallback { - pub fn new(env: &Env, call_override_callback: JsFunction) -> napi::Result { + pub fn new(env: &Env, call_override_callback: JsFunction, runtime: runtime::Handle) -> napi::Result { let mut call_override_callback_fn = call_override_callback.create_threadsafe_function( 0, |ctx: ThreadSafeCallContext| { @@ -68,6 +70,7 @@ impl CallOverrideCallback { Ok(Self { call_override_callback_fn, + runtime }) } @@ -78,20 +81,22 @@ impl CallOverrideCallback { ) -> Option { let (sender, receiver) = channel(); + let runtime = self.runtime.clone(); let status = self.call_override_callback_fn.call_with_return_value( CallOverrideCall { contract_address, data, }, ThreadsafeFunctionCallMode::Blocking, - move |result: Option| { - let result = result.try_cast(); - - sender.send(result).map_err(|_error| { - napi::Error::new( - Status::GenericFailure, - "Failed to send result from call_override_callback", - ) + move |result: Promise>| { + runtime.block_on(async { + let result = result.await?.try_cast(); + sender.send(result).map_err(|_error| { + napi::Error::new( + Status::GenericFailure, + "Failed to send result from call_override_callback", + ) + }) }) }, ); diff --git a/crates/edr_napi/src/provider.rs b/crates/edr_napi/src/provider.rs index 7d4ec1de1..a1020329a 100644 --- a/crates/edr_napi/src/provider.rs +++ b/crates/edr_napi/src/provider.rs @@ -20,6 +20,7 @@ use crate::{ #[napi] pub struct Provider { provider: Arc>, + runtime: runtime::Handle, #[cfg(feature = "scenarios")] scenario_file: Option>, } @@ -53,7 +54,7 @@ impl Provider { ))?; let result = edr_provider::Provider::new( - runtime, + runtime.clone(), logger, subscriber_callback, config, @@ -64,6 +65,7 @@ impl Provider { |provider| { Ok(Provider { provider: Arc::new(provider), + runtime, #[cfg(feature = "scenarios")] scenario_file, }) @@ -185,7 +187,7 @@ impl Provider { ) -> napi::Result<()> { let provider = self.provider.clone(); - let call_override_callback = CallOverrideCallback::new(&env, call_override_callback)?; + let call_override_callback = CallOverrideCallback::new(&env, call_override_callback, self.runtime.clone())?; let call_override_callback = Arc::new(move |address, data| call_override_callback.call_override(address, data)); From 7d36e1758003255ffddbbc0c0bdbb034d9cc675b Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Tue, 30 Apr 2024 19:45:59 +0200 Subject: [PATCH 02/18] Fix deadlock --- crates/edr_napi/src/call_override.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/edr_napi/src/call_override.rs b/crates/edr_napi/src/call_override.rs index ebf09afd5..a4e7f3824 100644 --- a/crates/edr_napi/src/call_override.rs +++ b/crates/edr_napi/src/call_override.rs @@ -89,7 +89,7 @@ impl CallOverrideCallback { }, ThreadsafeFunctionCallMode::Blocking, move |result: Promise>| { - runtime.block_on(async { + runtime.spawn(async move { let result = result.await?.try_cast(); sender.send(result).map_err(|_error| { napi::Error::new( @@ -97,7 +97,8 @@ impl CallOverrideCallback { "Failed to send result from call_override_callback", ) }) - }) + }); + Ok(()) }, ); From c2b404ff56cad9fbcdf8a087e9fe75d9fb6cb531 Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Thu, 2 May 2024 12:05:43 +0200 Subject: [PATCH 03/18] Add test --- crates/edr_napi/.gitignore | 4 + crates/edr_napi/hardhat.config.js | 9 + crates/edr_napi/package.json | 4 +- crates/edr_napi/test/contracts/FooBar.sol | 12 + crates/edr_napi/test/provider.ts | 25 ++ pnpm-lock.yaml | 339 ++++++++++++++++++++++ 6 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 crates/edr_napi/hardhat.config.js create mode 100644 crates/edr_napi/test/contracts/FooBar.sol diff --git a/crates/edr_napi/.gitignore b/crates/edr_napi/.gitignore index 033afc898..a3ed95ef0 100644 --- a/crates/edr_napi/.gitignore +++ b/crates/edr_napi/.gitignore @@ -96,3 +96,7 @@ typings/ # DynamoDB Local files .dynamodb/ + +# Hardhat output +artifacts +cache diff --git a/crates/edr_napi/hardhat.config.js b/crates/edr_napi/hardhat.config.js new file mode 100644 index 000000000..1fb7f7438 --- /dev/null +++ b/crates/edr_napi/hardhat.config.js @@ -0,0 +1,9 @@ +require("@nomiclabs/hardhat-ethers") + +/** @type import('hardhat/config').HardhatUserConfig */ +module.exports = { + paths: { + sources: './test/contracts', + }, + solidity: "0.8.24", +}; diff --git a/crates/edr_napi/package.json b/crates/edr_napi/package.json index b654e10dd..b74190bfd 100644 --- a/crates/edr_napi/package.json +++ b/crates/edr_napi/package.json @@ -27,7 +27,9 @@ }, "license": "MIT", "devDependencies": { + "@defi-wonderland/smock": "^2.4.0", "@napi-rs/cli": "^2.18.1", + "@nomiclabs/hardhat-ethers": "^2.2.3", "@types/chai": "^4.2.0", "@types/chai-as-promised": "^7.1.8", "@types/mocha": ">=9.1.0", @@ -50,7 +52,7 @@ "prepublishOnly": "napi prepublish -t npm --skip-gh-release", "universal": "napi universal", "version": "napi version", - "pretest": "pnpm build", + "pretest": "pnpm build && npx hardhat compile", "test": "pnpm tsc && mocha --recursive \"test/**/*.ts\"", "testNoBuild": "pnpm tsc && mocha --recursive \"test/**/*.ts\"", "clean": "rm -rf @nomicfoundation/edr.node" diff --git a/crates/edr_napi/test/contracts/FooBar.sol b/crates/edr_napi/test/contracts/FooBar.sol new file mode 100644 index 000000000..16a195a06 --- /dev/null +++ b/crates/edr_napi/test/contracts/FooBar.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +contract Foo { + function f() public {} +} + +contract Bar { + function callFoo(Foo foo) public { + foo.f(); + } +} diff --git a/crates/edr_napi/test/provider.ts b/crates/edr_napi/test/provider.ts index 6e347bd3f..bda9502fa 100644 --- a/crates/edr_napi/test/provider.ts +++ b/crates/edr_napi/test/provider.ts @@ -1,5 +1,7 @@ +import { smock } from "@defi-wonderland/smock"; import chai, { assert } from "chai"; import chaiAsPromised from "chai-as-promised"; + import { ContractAndFunctionName, EdrContext, @@ -101,4 +103,27 @@ describe("Provider", () => { await assert.isFulfilled(provider); }); + + // Ported from https://github.com/fvictorio/edr-smock-issue + it("set call override callback for smock", async function () { + // Hardhat doesn't work with ESM modules, so we have to require it here. + // The pretest hook runs compile. + const { ethers } = require("hardhat"); + + const provider = await Provider.withConfig( + context, + providerConfig, + loggerConfig, + (_event: SubscriptionEvent) => {} + ); + + // Test that we handle promise result appropriately in Rust + provider.setCallOverrideCallback(async (contractAddress, data) => undefined); + + const mockedFoo = await smock.fake('Foo'); + const Bar = await ethers.getContractFactory('Bar'); + const bar = await Bar.deploy(); + + await bar.callFoo(mockedFoo.address); + }); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d92c71027..12bd7c727 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,9 +20,15 @@ importers: crates/edr_napi: devDependencies: + '@defi-wonderland/smock': + specifier: ^2.4.0 + version: 2.4.0(@ethersproject/abi@5.7.0)(@ethersproject/abstract-provider@5.7.0)(@ethersproject/abstract-signer@5.7.0)(@nomiclabs/hardhat-ethers@2.2.3)(ethers@5.7.2)(hardhat@2.22.3) '@napi-rs/cli': specifier: ^2.18.1 version: 2.18.1 + '@nomiclabs/hardhat-ethers': + specifier: ^2.2.3 + version: 2.2.3(ethers@5.7.2)(hardhat@2.22.3) '@types/chai': specifier: ^4.2.0 version: 4.3.12 @@ -426,6 +432,32 @@ packages: '@jridgewell/trace-mapping': 0.3.9 dev: true + /@defi-wonderland/smock@2.4.0(@ethersproject/abi@5.7.0)(@ethersproject/abstract-provider@5.7.0)(@ethersproject/abstract-signer@5.7.0)(@nomiclabs/hardhat-ethers@2.2.3)(ethers@5.7.2)(hardhat@2.22.3): + resolution: {integrity: sha512-eS5fuAa9MOVDvXsT7Qa4v9Tg0Pk5ypfY3JWyW93a5sqyY2E2nCuRRBC53IikM9z0tVB2YYA8C9bWK8Lc47mATw==} + peerDependencies: + '@ethersproject/abi': ^5 + '@ethersproject/abstract-provider': ^5 + '@ethersproject/abstract-signer': ^5 + '@nomiclabs/hardhat-ethers': ^2 + ethers: ^5 + hardhat: ^2.21.0 + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@nomicfoundation/ethereumjs-util': 9.0.4 + '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.7.2)(hardhat@2.22.3) + diff: 5.0.0 + ethers: 5.7.2 + hardhat: 2.22.3(ts-node@10.9.2)(typescript@4.5.5) + lodash.isequal: 4.5.0 + lodash.isequalwith: 4.4.0 + rxjs: 7.8.1 + semver: 7.6.0 + transitivePeerDependencies: + - c-kzg + dev: true + /@esbuild/aix-ppc64@0.19.12: resolution: {integrity: sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==} engines: {node: '>=12'} @@ -717,6 +749,13 @@ packages: dependencies: '@ethersproject/bytes': 5.7.0 + /@ethersproject/basex@5.7.0: + resolution: {integrity: sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/properties': 5.7.0 + dev: true + /@ethersproject/bignumber@5.7.0: resolution: {integrity: sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw==} dependencies: @@ -734,6 +773,21 @@ packages: dependencies: '@ethersproject/bignumber': 5.7.0 + /@ethersproject/contracts@5.7.0: + resolution: {integrity: sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==} + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/logger': 5.0.6 + '@ethersproject/properties': 5.7.0 + '@ethersproject/transactions': 5.7.0 + dev: true + /@ethersproject/hash@5.7.0: resolution: {integrity: sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==} dependencies: @@ -747,12 +801,51 @@ packages: '@ethersproject/properties': 5.7.0 '@ethersproject/strings': 5.7.0 + /@ethersproject/hdnode@5.7.0: + resolution: {integrity: sha512-OmyYo9EENBPPf4ERhR7oj6uAtUAhYGqOnIS+jE5pTXvdKBS99ikzq1E7Iv0ZQZ5V36Lqx1qZLeak0Ra16qpeOg==} + dependencies: + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/basex': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/pbkdf2': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/wordlists': 5.7.0 + dev: true + + /@ethersproject/json-wallets@5.7.0: + resolution: {integrity: sha512-8oee5Xgu6+RKgJTkvEMl2wDgSPSAQ9MB/3JYjFV9jlKvcYHUXZC+cQp0njgmxdHkYWn8s6/IqIZYm0YWCjO/0g==} + dependencies: + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/hdnode': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/pbkdf2': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/random': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + aes-js: 3.0.0 + scrypt-js: 3.0.1 + dev: true + /@ethersproject/keccak256@5.7.0: resolution: {integrity: sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg==} dependencies: '@ethersproject/bytes': 5.7.0 js-sha3: 0.8.0 + /@ethersproject/logger@5.0.6: + resolution: {integrity: sha512-FrX0Vnb3JZ1md/7GIZfmJ06XOAA8r3q9Uqt9O5orr4ZiksnbpXKlyDzQtlZ5Yv18RS8CAUbiKH9vwidJg1BPmQ==} + dev: true + /@ethersproject/logger@5.7.0: resolution: {integrity: sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==} @@ -761,17 +854,67 @@ packages: dependencies: '@ethersproject/logger': 5.7.0 + /@ethersproject/pbkdf2@5.7.0: + resolution: {integrity: sha512-oR/dBRZR6GTyaofd86DehG72hY6NpAjhabkhxgr3X2FpJtJuodEl2auADWBZfhDHgVCbu3/H/Ocq2uC6dpNjjw==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/sha2': 5.7.0 + dev: true + /@ethersproject/properties@5.7.0: resolution: {integrity: sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw==} dependencies: '@ethersproject/logger': 5.7.0 + /@ethersproject/providers@5.7.2: + resolution: {integrity: sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==} + dependencies: + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/base64': 5.7.0 + '@ethersproject/basex': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/properties': 5.7.0 + '@ethersproject/random': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/web': 5.7.1 + bech32: 1.1.4 + ws: 7.4.6 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: true + + /@ethersproject/random@5.7.0: + resolution: {integrity: sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + dev: true + /@ethersproject/rlp@5.7.0: resolution: {integrity: sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w==} dependencies: '@ethersproject/bytes': 5.7.0 '@ethersproject/logger': 5.7.0 + /@ethersproject/sha2@5.7.0: + resolution: {integrity: sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/logger': 5.7.0 + hash.js: 1.1.7 + dev: true + /@ethersproject/signing-key@5.7.0: resolution: {integrity: sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q==} dependencies: @@ -782,6 +925,17 @@ packages: elliptic: 6.5.4 hash.js: 1.1.7 + /@ethersproject/solidity@5.7.0: + resolution: {integrity: sha512-HmabMd2Dt/raavyaGukF4XxizWKhKQ24DoLtdNbBmNKUOPqwjsKQSdV9GQtj9CBEea9DlzETlVER1gYeXXBGaA==} + dependencies: + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/strings': 5.7.0 + dev: true + /@ethersproject/strings@5.7.0: resolution: {integrity: sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg==} dependencies: @@ -802,6 +956,34 @@ packages: '@ethersproject/rlp': 5.7.0 '@ethersproject/signing-key': 5.7.0 + /@ethersproject/units@5.7.0: + resolution: {integrity: sha512-pD3xLMy3SJu9kG5xDGI7+xhTEmGXlEqXU4OfNapmfnxLVY4EMSSRp7j1k7eezutBPH7RBN/7QPnwR7hzNlEFeg==} + dependencies: + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/logger': 5.7.0 + dev: true + + /@ethersproject/wallet@5.7.0: + resolution: {integrity: sha512-MhmXlJXEJFBFVKrDLB4ZdDzxcBxQ3rLyCkhNqVu3CDYvR97E+8r01UgrI+TI99Le+aYm/in/0vp86guJuM7FCA==} + dependencies: + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/hdnode': 5.7.0 + '@ethersproject/json-wallets': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/random': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/wordlists': 5.7.0 + dev: true + /@ethersproject/web@5.7.1: resolution: {integrity: sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==} dependencies: @@ -811,6 +993,16 @@ packages: '@ethersproject/properties': 5.7.0 '@ethersproject/strings': 5.7.0 + /@ethersproject/wordlists@5.7.0: + resolution: {integrity: sha512-S2TFNJNfHWVHNE6cNDjbVlZ6MgE17MIxMbMg2zv3wn+3XSJGosL1m9ZVv3GXCf/2ymSsQ+hRI5IzoMJTG6aoVA==} + dependencies: + '@ethersproject/bytes': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/strings': 5.7.0 + dev: true + /@fastify/busboy@2.1.0: resolution: {integrity: sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==} engines: {node: '>=14'} @@ -1086,6 +1278,16 @@ packages: '@nomicfoundation/solidity-analyzer-win32-ia32-msvc': 0.1.1 '@nomicfoundation/solidity-analyzer-win32-x64-msvc': 0.1.1 + /@nomiclabs/hardhat-ethers@2.2.3(ethers@5.7.2)(hardhat@2.22.3): + resolution: {integrity: sha512-YhzPdzb612X591FOe68q+qXVXGG2ANZRvDo0RRUtimev85rCrAlv/TLMEZw5c+kq9AbzocLTVX/h2jVIFPL9Xg==} + peerDependencies: + ethers: ^5.0.0 + hardhat: ^2.0.0 + dependencies: + ethers: 5.7.2 + hardhat: 2.22.3(ts-node@10.9.2)(typescript@4.5.5) + dev: true + /@scure/base@1.1.5: resolution: {integrity: sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==} @@ -1516,6 +1718,10 @@ packages: resolution: {integrity: sha512-TFi4HBKSGfIKsK5YCkKaaFG2m4PEDyViZmEwof3MTIgzimHLto6muaHVpbrljdIvIrFZzEq/p4nafOeLcYegrg==} engines: {node: '>=0.3.0'} + /aes-js@3.0.0: + resolution: {integrity: sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==} + dev: true + /aes-js@4.0.0-beta.5: resolution: {integrity: sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==} dev: true @@ -1681,6 +1887,10 @@ packages: dependencies: safe-buffer: 5.2.1 + /bech32@1.1.4: + resolution: {integrity: sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==} + dev: true + /better-path-resolve@1.0.0: resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} engines: {node: '>=4'} @@ -2616,6 +2826,44 @@ packages: ethjs-util: 0.1.6 rlp: 2.2.7 + /ethers@5.7.2: + resolution: {integrity: sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg==} + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/base64': 5.7.0 + '@ethersproject/basex': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/contracts': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/hdnode': 5.7.0 + '@ethersproject/json-wallets': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/logger': 5.7.0 + '@ethersproject/networks': 5.7.1 + '@ethersproject/pbkdf2': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/providers': 5.7.2 + '@ethersproject/random': 5.7.0 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/sha2': 5.7.0 + '@ethersproject/signing-key': 5.7.0 + '@ethersproject/solidity': 5.7.0 + '@ethersproject/strings': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/units': 5.7.0 + '@ethersproject/wallet': 5.7.0 + '@ethersproject/web': 5.7.1 + '@ethersproject/wordlists': 5.7.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: true + /ethers@6.12.0: resolution: {integrity: sha512-zL5NlOTjML239gIvtVJuaSk0N9GQLi1Hom3ZWUszE5lDTQE/IVB62mrPkQ2W1bGcZwVGSLaetQbWNQSvI4rGDQ==} engines: {node: '>=14.0.0'} @@ -2938,6 +3186,70 @@ packages: engines: {node: '>=6'} dev: true + /hardhat@2.22.3(ts-node@10.9.2)(typescript@4.5.5): + resolution: {integrity: sha512-k8JV2ECWNchD6ahkg2BR5wKVxY0OiKot7fuxiIpRK0frRqyOljcR2vKwgWSLw6YIeDcNNA4xybj7Og7NSxr2hA==} + hasBin: true + peerDependencies: + ts-node: '*' + typescript: '*' + peerDependenciesMeta: + ts-node: + optional: true + typescript: + optional: true + dependencies: + '@ethersproject/abi': 5.7.0 + '@metamask/eth-sig-util': 4.0.1 + '@nomicfoundation/edr': link:crates/edr_napi + '@nomicfoundation/ethereumjs-common': 4.0.4 + '@nomicfoundation/ethereumjs-tx': 5.0.4 + '@nomicfoundation/ethereumjs-util': 9.0.4 + '@nomicfoundation/solidity-analyzer': 0.1.1 + '@sentry/node': 5.30.0 + '@types/bn.js': 5.1.5 + '@types/lru-cache': 5.1.1 + adm-zip: 0.4.16 + aggregate-error: 3.1.0 + ansi-escapes: 4.3.2 + boxen: 5.1.2 + chalk: 2.4.2 + chokidar: 3.6.0 + ci-info: 2.0.0 + debug: 4.3.4(supports-color@8.1.1) + enquirer: 2.4.1 + env-paths: 2.2.1 + ethereum-cryptography: 1.2.0 + ethereumjs-abi: 0.6.8 + find-up: 2.1.0 + fp-ts: 1.19.3 + fs-extra: 7.0.1 + glob: 7.2.0 + immutable: 4.3.5 + io-ts: 1.10.4 + keccak: 3.0.4 + lodash: 4.17.21 + mnemonist: 0.38.5 + mocha: 10.3.0 + p-map: 4.0.0 + raw-body: 2.5.2 + resolve: 1.17.0 + semver: 6.3.1 + solc: 0.7.3(debug@4.3.4) + source-map-support: 0.5.21 + stacktrace-parser: 0.1.10 + ts-node: 10.9.2(@types/node@18.15.13)(typescript@4.5.5) + tsort: 0.0.1 + typescript: 4.5.5 + undici: 5.28.3 + uuid: 8.3.2 + ws: 7.5.9 + transitivePeerDependencies: + - bufferutil + - c-kzg + - supports-color + - utf-8-validate + dev: true + /hardhat@2.22.3(ts-node@9.1.1)(typescript@5.0.4): resolution: {integrity: sha512-k8JV2ECWNchD6ahkg2BR5wKVxY0OiKot7fuxiIpRK0frRqyOljcR2vKwgWSLw6YIeDcNNA4xybj7Og7NSxr2hA==} hasBin: true @@ -3463,6 +3775,14 @@ packages: resolution: {integrity: sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==} dev: true + /lodash.isequal@4.5.0: + resolution: {integrity: sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==} + dev: true + + /lodash.isequalwith@4.4.0: + resolution: {integrity: sha512-dcZON0IalGBpRmJBmMkaoV7d3I80R2O+FrzsZyHdNSFrANq/cgDqKQNmAHE8UEj4+QYWwwhkQOVdLHiAopzlsQ==} + dev: true + /lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} dev: true @@ -4103,6 +4423,12 @@ packages: queue-microtask: 1.2.3 dev: true + /rxjs@7.8.1: + resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==} + dependencies: + tslib: 2.4.0 + dev: true + /safe-array-concat@1.1.2: resolution: {integrity: sha512-vj6RsCsWBCf19jIeHEfkRMw8DPiBb+DMXklQ/1SGDHOMlHdPUkZXFQ2YdplS23zESTijAcurb1aSgJA3AgMu1Q==} engines: {node: '>=0.4'} @@ -4799,6 +5125,19 @@ packages: /wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + /ws@7.4.6: + resolution: {integrity: sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==} + engines: {node: '>=8.3.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + dev: true + /ws@7.5.9: resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==} engines: {node: '>=8.3.0'} From c8e462d96513ce981b2c7184da0ad758f54453a5 Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Thu, 2 May 2024 12:06:53 +0200 Subject: [PATCH 04/18] Fail test intentionally in CI to make sure it runs --- crates/edr_napi/test/provider.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/edr_napi/test/provider.ts b/crates/edr_napi/test/provider.ts index bda9502fa..ba237ad66 100644 --- a/crates/edr_napi/test/provider.ts +++ b/crates/edr_napi/test/provider.ts @@ -125,5 +125,7 @@ describe("Provider", () => { const bar = await Bar.deploy(); await bar.callFoo(mockedFoo.address); + + assert(false, "Fail test intentionally in CI"); }); }); From df06eca1ac68c8568dbecbe5d4b4ce0f0ed754a7 Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Thu, 2 May 2024 12:28:45 +0200 Subject: [PATCH 05/18] Add changeset --- .changeset/nasty-teachers-brush.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/nasty-teachers-brush.md diff --git a/.changeset/nasty-teachers-brush.md b/.changeset/nasty-teachers-brush.md new file mode 100644 index 000000000..d56dd234e --- /dev/null +++ b/.changeset/nasty-teachers-brush.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/edr": patch +--- + +Fixed `smock.fake` causing a panic From 539de1e3c052c0929583c539a28dfd879a757db9 Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Thu, 2 May 2024 12:29:04 +0200 Subject: [PATCH 06/18] Fix formatting --- crates/edr_napi/src/call_override.rs | 8 ++++++-- crates/edr_napi/src/provider.rs | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/edr_napi/src/call_override.rs b/crates/edr_napi/src/call_override.rs index a4e7f3824..175e05522 100644 --- a/crates/edr_napi/src/call_override.rs +++ b/crates/edr_napi/src/call_override.rs @@ -46,7 +46,11 @@ pub struct CallOverrideCallback { } impl CallOverrideCallback { - pub fn new(env: &Env, call_override_callback: JsFunction, runtime: runtime::Handle) -> napi::Result { + pub fn new( + env: &Env, + call_override_callback: JsFunction, + runtime: runtime::Handle, + ) -> napi::Result { let mut call_override_callback_fn = call_override_callback.create_threadsafe_function( 0, |ctx: ThreadSafeCallContext| { @@ -70,7 +74,7 @@ impl CallOverrideCallback { Ok(Self { call_override_callback_fn, - runtime + runtime, }) } diff --git a/crates/edr_napi/src/provider.rs b/crates/edr_napi/src/provider.rs index a1020329a..541437426 100644 --- a/crates/edr_napi/src/provider.rs +++ b/crates/edr_napi/src/provider.rs @@ -187,7 +187,8 @@ impl Provider { ) -> napi::Result<()> { let provider = self.provider.clone(); - let call_override_callback = CallOverrideCallback::new(&env, call_override_callback, self.runtime.clone())?; + let call_override_callback = + CallOverrideCallback::new(&env, call_override_callback, self.runtime.clone())?; let call_override_callback = Arc::new(move |address, data| call_override_callback.call_override(address, data)); From 0320efeb5a31b396c851612603ac7889936ba6cb Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Thu, 2 May 2024 12:29:27 +0200 Subject: [PATCH 07/18] Revert "Fail test intentionally in CI to make sure it runs" This reverts commit c8e462d96513ce981b2c7184da0ad758f54453a5. --- crates/edr_napi/test/provider.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/edr_napi/test/provider.ts b/crates/edr_napi/test/provider.ts index ba237ad66..bda9502fa 100644 --- a/crates/edr_napi/test/provider.ts +++ b/crates/edr_napi/test/provider.ts @@ -125,7 +125,5 @@ describe("Provider", () => { const bar = await Bar.deploy(); await bar.callFoo(mockedFoo.address); - - assert(false, "Fail test intentionally in CI"); }); }); From df3bc94de1e238bfcc5fc3d997f630cdca07b05f Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Thu, 2 May 2024 12:32:46 +0200 Subject: [PATCH 08/18] Fix testing released artifact --- .github/workflows/edr-npm-release.yml | 10 +++++----- crates/edr_napi/package.json | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/edr-npm-release.yml b/.github/workflows/edr-npm-release.yml index c80502962..9640827ee 100644 --- a/.github/workflows/edr-npm-release.yml +++ b/.github/workflows/edr-npm-release.yml @@ -185,7 +185,7 @@ jobs: run: ls -R . shell: bash - name: Test bindings - run: pnpm testNoBuild + run: pnpm testArtifact test-linux-x64-gnu-binding: name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} needs: @@ -219,7 +219,7 @@ jobs: run: ls -R . shell: bash - name: Test bindings - run: docker run --rm -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }} bash -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testNoBuild" + run: docker run --rm -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }} bash -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testArtifact" test-linux-x64-musl-binding: name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }} needs: @@ -255,7 +255,7 @@ jobs: run: ls -R . shell: bash - name: Test bindings - run: docker run --rm -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }}-alpine sh -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testNoBuild" + run: docker run --rm -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }}-alpine sh -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testArtifact" test-linux-aarch64-gnu-binding: name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} needs: @@ -298,7 +298,7 @@ jobs: run: | wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node set -e - pnpm testNoBuild + pnpm testArtifact ls -la test-linux-aarch64-musl-binding: name: Test bindings on aarch64-unknown-linux-musl - node@lts @@ -336,7 +336,7 @@ jobs: run: | wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node set -e - pnpm testNoBuild + pnpm testArtifact check_commit: name: Check commit runs-on: ubuntu-22.04 diff --git a/crates/edr_napi/package.json b/crates/edr_napi/package.json index b74190bfd..dfce787a2 100644 --- a/crates/edr_napi/package.json +++ b/crates/edr_napi/package.json @@ -54,7 +54,8 @@ "version": "napi version", "pretest": "pnpm build && npx hardhat compile", "test": "pnpm tsc && mocha --recursive \"test/**/*.ts\"", - "testNoBuild": "pnpm tsc && mocha --recursive \"test/**/*.ts\"", + "pretestArtifact": "pnpm install --frozen-lockfile --prefer-offline && pnpm tsc && npx hardhat compile", + "testArtifact": "mocha --recursive \"test/**/*.ts\"", "clean": "rm -rf @nomicfoundation/edr.node" } } From 07887a954520f255e1d0ea3885459e696d2c742d Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Thu, 2 May 2024 13:18:52 +0200 Subject: [PATCH 09/18] Fix testing released artifact --- crates/edr_napi/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/edr_napi/package.json b/crates/edr_napi/package.json index dfce787a2..2f2e0eb45 100644 --- a/crates/edr_napi/package.json +++ b/crates/edr_napi/package.json @@ -54,7 +54,7 @@ "version": "napi version", "pretest": "pnpm build && npx hardhat compile", "test": "pnpm tsc && mocha --recursive \"test/**/*.ts\"", - "pretestArtifact": "pnpm install --frozen-lockfile --prefer-offline && pnpm tsc && npx hardhat compile", + "pretestArtifact": "CI=1 pnpm install --frozen-lockfile --prefer-offline && pnpm tsc && npx hardhat compile", "testArtifact": "mocha --recursive \"test/**/*.ts\"", "clean": "rm -rf @nomicfoundation/edr.node" } From 230cdb52d77997288472e0174ca9234c1160917d Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Thu, 2 May 2024 14:21:05 +0200 Subject: [PATCH 10/18] Fix testing released artifact --- crates/edr_napi/package.json | 1 + pnpm-lock.yaml | 22 +++++++--------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/crates/edr_napi/package.json b/crates/edr_napi/package.json index 2f2e0eb45..34bff88b0 100644 --- a/crates/edr_napi/package.json +++ b/crates/edr_napi/package.json @@ -36,6 +36,7 @@ "@types/node": "^18.0.0", "chai": "^4.3.6", "chai-as-promised": "^7.1.1", + "hardhat": "^2.22.3", "mocha": "^10.0.0", "ts-node": "^10.8.0", "typescript": "~4.5.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 12bd7c727..40d16919c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -47,6 +47,9 @@ importers: chai-as-promised: specifier: ^7.1.1 version: 7.1.1(chai@4.4.1) + hardhat: + specifier: ^2.22.3 + version: 2.22.3(ts-node@10.9.2)(typescript@4.5.5) mocha: specifier: ^10.0.0 version: 10.3.0 @@ -64,7 +67,7 @@ importers: version: 2.0.1 hardhat: specifier: ^2.22.3 - version: 2.22.3(ts-node@9.1.1)(typescript@5.0.4) + version: 2.22.3(ts-node@10.9.2)(typescript@4.5.5) lodash: specifier: ^4.17.11 version: 4.17.21 @@ -430,7 +433,6 @@ packages: engines: {node: '>=12'} dependencies: '@jridgewell/trace-mapping': 0.3.9 - dev: true /@defi-wonderland/smock@2.4.0(@ethersproject/abi@5.7.0)(@ethersproject/abstract-provider@5.7.0)(@ethersproject/abstract-signer@5.7.0)(@nomiclabs/hardhat-ethers@2.2.3)(ethers@5.7.2)(hardhat@2.22.3): resolution: {integrity: sha512-eS5fuAa9MOVDvXsT7Qa4v9Tg0Pk5ypfY3JWyW93a5sqyY2E2nCuRRBC53IikM9z0tVB2YYA8C9bWK8Lc47mATw==} @@ -1030,18 +1032,15 @@ packages: /@jridgewell/resolve-uri@3.1.2: resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} - dev: true /@jridgewell/sourcemap-codec@1.4.15: resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} - dev: true /@jridgewell/trace-mapping@0.3.9: resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} dependencies: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.4.15 - dev: true /@manypkg/find-root@1.1.0: resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} @@ -1393,19 +1392,15 @@ packages: /@tsconfig/node10@1.0.11: resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==} - dev: true /@tsconfig/node12@1.0.11: resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} - dev: true /@tsconfig/node14@1.0.3: resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} - dev: true /@tsconfig/node16@1.0.4: resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} - dev: true /@types/async-eventemitter@0.2.4: resolution: {integrity: sha512-2Bq61VD01kgLf1XkK2xPtoBcu7fgn/km5JyEX9v0BlG5VQBzA+BlF9umFk+8gR8S4+eK7MgDY2oyVZCu6ar3Jw==} @@ -1706,13 +1701,11 @@ packages: /acorn-walk@8.3.2: resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} engines: {node: '>=0.4.0'} - dev: true /acorn@8.11.3: resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==} engines: {node: '>=0.4.0'} hasBin: true - dev: true /adm-zip@0.4.16: resolution: {integrity: sha512-TFi4HBKSGfIKsK5YCkKaaFG2m4PEDyViZmEwof3MTIgzimHLto6muaHVpbrljdIvIrFZzEq/p4nafOeLcYegrg==} @@ -3248,7 +3241,6 @@ packages: - c-kzg - supports-color - utf-8-validate - dev: true /hardhat@2.22.3(ts-node@9.1.1)(typescript@5.0.4): resolution: {integrity: sha512-k8JV2ECWNchD6ahkg2BR5wKVxY0OiKot7fuxiIpRK0frRqyOljcR2vKwgWSLw6YIeDcNNA4xybj7Og7NSxr2hA==} @@ -3312,6 +3304,7 @@ packages: - c-kzg - supports-color - utf-8-validate + dev: true /has-bigints@1.0.2: resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==} @@ -4824,7 +4817,6 @@ packages: typescript: 4.5.5 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 - dev: true /ts-node@9.1.1(typescript@5.0.4): resolution: {integrity: sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==} @@ -4840,6 +4832,7 @@ packages: source-map-support: 0.5.21 typescript: 5.0.4 yn: 3.1.1 + dev: true /tsconfig-paths@3.15.0: resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} @@ -4988,12 +4981,12 @@ packages: resolution: {integrity: sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==} engines: {node: '>=4.2.0'} hasBin: true - dev: true /typescript@5.0.4: resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} engines: {node: '>=12.20'} hasBin: true + dev: true /unbox-primitive@1.0.2: resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} @@ -5033,7 +5026,6 @@ packages: /v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} - dev: true /validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} From 743340a02b35c54816c1d5bed467ab90b3787c7b Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Thu, 2 May 2024 15:27:11 +0200 Subject: [PATCH 11/18] Fix testing released artifact --- .github/workflows/edr-npm-release.yml | 3 +++ crates/edr_napi/package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/edr-npm-release.yml b/.github/workflows/edr-npm-release.yml index 9640827ee..96e63a9db 100644 --- a/.github/workflows/edr-npm-release.yml +++ b/.github/workflows/edr-npm-release.yml @@ -4,6 +4,9 @@ env: DEBUG: napi:* APP_NAME: edr MACOSX_DEPLOYMENT_TARGET: "10.13" + # Important to make PNPM install non-interactive + # https://github.com/pnpm/pnpm/issues/6615#issuecomment-1656945689 + CI: 1 permissions: contents: write id-token: write diff --git a/crates/edr_napi/package.json b/crates/edr_napi/package.json index 34bff88b0..cc302e9be 100644 --- a/crates/edr_napi/package.json +++ b/crates/edr_napi/package.json @@ -55,7 +55,7 @@ "version": "napi version", "pretest": "pnpm build && npx hardhat compile", "test": "pnpm tsc && mocha --recursive \"test/**/*.ts\"", - "pretestArtifact": "CI=1 pnpm install --frozen-lockfile --prefer-offline && pnpm tsc && npx hardhat compile", + "pretestArtifact": "pnpm install && pnpm tsc && npx hardhat compile", "testArtifact": "mocha --recursive \"test/**/*.ts\"", "clean": "rm -rf @nomicfoundation/edr.node" } From d3acccd833953e78e604836a169e0c11ea57ae3f Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Thu, 2 May 2024 15:44:16 +0200 Subject: [PATCH 12/18] Fix testing released artifact --- .github/workflows/edr-npm-release.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/edr-npm-release.yml b/.github/workflows/edr-npm-release.yml index 96e63a9db..9f962100e 100644 --- a/.github/workflows/edr-npm-release.yml +++ b/.github/workflows/edr-npm-release.yml @@ -4,9 +4,6 @@ env: DEBUG: napi:* APP_NAME: edr MACOSX_DEPLOYMENT_TARGET: "10.13" - # Important to make PNPM install non-interactive - # https://github.com/pnpm/pnpm/issues/6615#issuecomment-1656945689 - CI: 1 permissions: contents: write id-token: write @@ -222,7 +219,9 @@ jobs: run: ls -R . shell: bash - name: Test bindings - run: docker run --rm -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }} bash -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testArtifact" + # Setting CI=1 is important to make PNPM install non-interactive + # https://github.com/pnpm/pnpm/issues/6615#issuecomment-1656945689 + run: docker run --rm -e CI=1 -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }} bash -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testArtifact" test-linux-x64-musl-binding: name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }} needs: @@ -258,7 +257,7 @@ jobs: run: ls -R . shell: bash - name: Test bindings - run: docker run --rm -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }}-alpine sh -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testArtifact" + run: docker run --rm -e CI=1 -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }}-alpine sh -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testArtifact" test-linux-aarch64-gnu-binding: name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} needs: @@ -297,7 +296,7 @@ jobs: uses: addnab/docker-run-action@v3 with: image: node:${{ matrix.node }} - options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build/crates/edr_napi" + options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build/crates/edr_napi -e CI=1" run: | wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node set -e @@ -335,7 +334,7 @@ jobs: uses: addnab/docker-run-action@v3 with: image: node:lts-alpine - options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build/crates/edr_napi" + options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build/crates/edr_napi -e CI=1" run: | wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node set -e From 6111e31179c8ec24c88eb7cf3c4794d93f51f265 Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Thu, 2 May 2024 16:47:25 +0200 Subject: [PATCH 13/18] Fix testing released artifact --- crates/edr_napi/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/edr_napi/package.json b/crates/edr_napi/package.json index cc302e9be..d21cdbb65 100644 --- a/crates/edr_napi/package.json +++ b/crates/edr_napi/package.json @@ -56,7 +56,7 @@ "pretest": "pnpm build && npx hardhat compile", "test": "pnpm tsc && mocha --recursive \"test/**/*.ts\"", "pretestArtifact": "pnpm install && pnpm tsc && npx hardhat compile", - "testArtifact": "mocha --recursive \"test/**/*.ts\"", + "testArtifact": "mocha --recursive \"test/**/*.ts\" --timeout 60000", "clean": "rm -rf @nomicfoundation/edr.node" } } From abf6890e5f2924f79bc33b58624b3d829e6e8b8a Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Fri, 3 May 2024 11:12:17 +0200 Subject: [PATCH 14/18] Move smock integration test under hardhat-tests --- .github/workflows/edr-npm-release.yml | 10 ++--- crates/edr_napi/.gitignore | 4 -- crates/edr_napi/package.json | 8 +--- crates/edr_napi/test/provider.ts | 24 ----------- hardhat-tests/integration/.gitignore | 3 ++ .../integration/smock}/contracts/FooBar.sol | 0 .../integration/smock}/hardhat.config.js | 3 -- hardhat-tests/integration/smock/package.json | 17 ++++++++ hardhat-tests/integration/smock/test/test.js | 18 ++++++++ hardhat-tests/package.json | 2 +- hardhat-tests/run-integration-tests.sh | 13 ++++++ pnpm-lock.yaml | 43 +++++++++++++++---- pnpm-workspace.yaml | 1 + 13 files changed, 94 insertions(+), 52 deletions(-) create mode 100644 hardhat-tests/integration/.gitignore rename {crates/edr_napi/test => hardhat-tests/integration/smock}/contracts/FooBar.sol (100%) rename {crates/edr_napi => hardhat-tests/integration/smock}/hardhat.config.js (73%) create mode 100644 hardhat-tests/integration/smock/package.json create mode 100644 hardhat-tests/integration/smock/test/test.js create mode 100755 hardhat-tests/run-integration-tests.sh diff --git a/.github/workflows/edr-npm-release.yml b/.github/workflows/edr-npm-release.yml index 9f962100e..be3353a64 100644 --- a/.github/workflows/edr-npm-release.yml +++ b/.github/workflows/edr-npm-release.yml @@ -185,7 +185,7 @@ jobs: run: ls -R . shell: bash - name: Test bindings - run: pnpm testArtifact + run: pnpm testNoBuild test-linux-x64-gnu-binding: name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} needs: @@ -221,7 +221,7 @@ jobs: - name: Test bindings # Setting CI=1 is important to make PNPM install non-interactive # https://github.com/pnpm/pnpm/issues/6615#issuecomment-1656945689 - run: docker run --rm -e CI=1 -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }} bash -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testArtifact" + run: docker run --rm -e CI=1 -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }} bash -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testNoBuild" test-linux-x64-musl-binding: name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }} needs: @@ -257,7 +257,7 @@ jobs: run: ls -R . shell: bash - name: Test bindings - run: docker run --rm -e CI=1 -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }}-alpine sh -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testArtifact" + run: docker run --rm -e CI=1 -v $(pwd):/build -w /build/crates/edr_napi node:${{ matrix.node }}-alpine sh -c "wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node; pnpm testNoBuild" test-linux-aarch64-gnu-binding: name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} needs: @@ -300,7 +300,7 @@ jobs: run: | wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node set -e - pnpm testArtifact + pnpm testNoBuild ls -la test-linux-aarch64-musl-binding: name: Test bindings on aarch64-unknown-linux-musl - node@lts @@ -338,7 +338,7 @@ jobs: run: | wget -qO- 'https://unpkg.com/@pnpm/self-installer' | node set -e - pnpm testArtifact + pnpm testNoBuild check_commit: name: Check commit runs-on: ubuntu-22.04 diff --git a/crates/edr_napi/.gitignore b/crates/edr_napi/.gitignore index a3ed95ef0..033afc898 100644 --- a/crates/edr_napi/.gitignore +++ b/crates/edr_napi/.gitignore @@ -96,7 +96,3 @@ typings/ # DynamoDB Local files .dynamodb/ - -# Hardhat output -artifacts -cache diff --git a/crates/edr_napi/package.json b/crates/edr_napi/package.json index d21cdbb65..b654e10dd 100644 --- a/crates/edr_napi/package.json +++ b/crates/edr_napi/package.json @@ -27,16 +27,13 @@ }, "license": "MIT", "devDependencies": { - "@defi-wonderland/smock": "^2.4.0", "@napi-rs/cli": "^2.18.1", - "@nomiclabs/hardhat-ethers": "^2.2.3", "@types/chai": "^4.2.0", "@types/chai-as-promised": "^7.1.8", "@types/mocha": ">=9.1.0", "@types/node": "^18.0.0", "chai": "^4.3.6", "chai-as-promised": "^7.1.1", - "hardhat": "^2.22.3", "mocha": "^10.0.0", "ts-node": "^10.8.0", "typescript": "~4.5.2" @@ -53,10 +50,9 @@ "prepublishOnly": "napi prepublish -t npm --skip-gh-release", "universal": "napi universal", "version": "napi version", - "pretest": "pnpm build && npx hardhat compile", + "pretest": "pnpm build", "test": "pnpm tsc && mocha --recursive \"test/**/*.ts\"", - "pretestArtifact": "pnpm install && pnpm tsc && npx hardhat compile", - "testArtifact": "mocha --recursive \"test/**/*.ts\" --timeout 60000", + "testNoBuild": "pnpm tsc && mocha --recursive \"test/**/*.ts\"", "clean": "rm -rf @nomicfoundation/edr.node" } } diff --git a/crates/edr_napi/test/provider.ts b/crates/edr_napi/test/provider.ts index bda9502fa..772f2b389 100644 --- a/crates/edr_napi/test/provider.ts +++ b/crates/edr_napi/test/provider.ts @@ -1,4 +1,3 @@ -import { smock } from "@defi-wonderland/smock"; import chai, { assert } from "chai"; import chaiAsPromised from "chai-as-promised"; @@ -103,27 +102,4 @@ describe("Provider", () => { await assert.isFulfilled(provider); }); - - // Ported from https://github.com/fvictorio/edr-smock-issue - it("set call override callback for smock", async function () { - // Hardhat doesn't work with ESM modules, so we have to require it here. - // The pretest hook runs compile. - const { ethers } = require("hardhat"); - - const provider = await Provider.withConfig( - context, - providerConfig, - loggerConfig, - (_event: SubscriptionEvent) => {} - ); - - // Test that we handle promise result appropriately in Rust - provider.setCallOverrideCallback(async (contractAddress, data) => undefined); - - const mockedFoo = await smock.fake('Foo'); - const Bar = await ethers.getContractFactory('Bar'); - const bar = await Bar.deploy(); - - await bar.callFoo(mockedFoo.address); - }); }); diff --git a/hardhat-tests/integration/.gitignore b/hardhat-tests/integration/.gitignore new file mode 100644 index 000000000..47f2cb0c8 --- /dev/null +++ b/hardhat-tests/integration/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +artifacts/ +cache/ diff --git a/crates/edr_napi/test/contracts/FooBar.sol b/hardhat-tests/integration/smock/contracts/FooBar.sol similarity index 100% rename from crates/edr_napi/test/contracts/FooBar.sol rename to hardhat-tests/integration/smock/contracts/FooBar.sol diff --git a/crates/edr_napi/hardhat.config.js b/hardhat-tests/integration/smock/hardhat.config.js similarity index 73% rename from crates/edr_napi/hardhat.config.js rename to hardhat-tests/integration/smock/hardhat.config.js index 1fb7f7438..3ab0cb6fe 100644 --- a/crates/edr_napi/hardhat.config.js +++ b/hardhat-tests/integration/smock/hardhat.config.js @@ -2,8 +2,5 @@ require("@nomiclabs/hardhat-ethers") /** @type import('hardhat/config').HardhatUserConfig */ module.exports = { - paths: { - sources: './test/contracts', - }, solidity: "0.8.24", }; diff --git a/hardhat-tests/integration/smock/package.json b/hardhat-tests/integration/smock/package.json new file mode 100644 index 000000000..d085622bc --- /dev/null +++ b/hardhat-tests/integration/smock/package.json @@ -0,0 +1,17 @@ +{ + "name": "hardhat-edr-smock-test", + "private": true, + "version": "1.0.0", + "description": "", + "main": "index.js", + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@defi-wonderland/smock": "^2.4.0", + "@nomiclabs/hardhat-ethers": "^2.2.3", + "chai": "^4.3.6", + "hardhat": "^2.22.3", + "mocha": "^10.0.0" + } +} diff --git a/hardhat-tests/integration/smock/test/test.js b/hardhat-tests/integration/smock/test/test.js new file mode 100644 index 000000000..1e07cbb54 --- /dev/null +++ b/hardhat-tests/integration/smock/test/test.js @@ -0,0 +1,18 @@ +const { smock } = require("@defi-wonderland/smock"); +const { assert } = require("chai"); +const chaiAsPromised = require("chai-as-promised"); + +describe("HH+EDR and smock", function () { + // Ported from https://github.com/fvictorio/edr-smock-issue + it("set call override callback for smock", async function () { + // Hardhat doesn't work with ESM modules, so we have to require it here. + // The pretest hook runs compile. + const { ethers } = require("hardhat"); + + const mockedFoo = await smock.fake("Foo"); + const Bar = await ethers.getContractFactory("Bar"); + const bar = await Bar.deploy(); + + await bar.callFoo(mockedFoo.address); + }); +}); diff --git a/hardhat-tests/package.json b/hardhat-tests/package.json index e7d9780ab..3e044842b 100644 --- a/hardhat-tests/package.json +++ b/hardhat-tests/package.json @@ -11,7 +11,7 @@ "eslint": "eslint 'test/**/*.ts'", "prettier": "prettier \"**/*.{js,md,json}\"", "pretest": "cd ../crates/edr_napi && pnpm build", - "test": "mocha --recursive \"test/**/*.ts\"", + "test": "mocha --recursive \"test/**/*.ts\" && ./run-integration-tests.sh", "build": "tsc --build --force --incremental .", "clean": "rimraf build-test tsconfig.tsbuildinfo test/internal/hardhat-network/provider/.hardhat_node_test_cache test/internal/hardhat-network/stack-traces/test-files/artifacts" }, diff --git a/hardhat-tests/run-integration-tests.sh b/hardhat-tests/run-integration-tests.sh new file mode 100755 index 000000000..44c5e7deb --- /dev/null +++ b/hardhat-tests/run-integration-tests.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e + +cd integration +for i in *; do + if [ -d "$i" ]; then + echo "Running integration test: '$i'" + cd $i + pnpm hardhat test + cd .. + fi +done diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 40d16919c..3809359fd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -67,7 +67,7 @@ importers: version: 2.0.1 hardhat: specifier: ^2.22.3 - version: 2.22.3(ts-node@10.9.2)(typescript@4.5.5) + version: 2.22.3(ts-node@9.1.1)(typescript@5.0.4) lodash: specifier: ^4.17.11 version: 4.17.21 @@ -204,6 +204,24 @@ importers: specifier: ^5.14.0 version: 5.28.3 + hardhat-tests/integration/smock: + devDependencies: + '@defi-wonderland/smock': + specifier: ^2.4.0 + version: 2.4.0(@ethersproject/abi@5.7.0)(@ethersproject/abstract-provider@5.7.0)(@ethersproject/abstract-signer@5.7.0)(@nomiclabs/hardhat-ethers@2.2.3)(ethers@5.7.2)(hardhat@2.22.3) + '@nomiclabs/hardhat-ethers': + specifier: ^2.2.3 + version: 2.2.3(ethers@5.7.2)(hardhat@2.22.3) + chai: + specifier: ^4.3.6 + version: 4.4.1 + hardhat: + specifier: ^2.22.3 + version: 2.22.3(ts-node@9.1.1)(typescript@5.0.4) + mocha: + specifier: ^10.0.0 + version: 10.3.0 + packages: /@aashutoshrathi/word-wrap@1.2.6: @@ -433,6 +451,7 @@ packages: engines: {node: '>=12'} dependencies: '@jridgewell/trace-mapping': 0.3.9 + dev: true /@defi-wonderland/smock@2.4.0(@ethersproject/abi@5.7.0)(@ethersproject/abstract-provider@5.7.0)(@ethersproject/abstract-signer@5.7.0)(@nomiclabs/hardhat-ethers@2.2.3)(ethers@5.7.2)(hardhat@2.22.3): resolution: {integrity: sha512-eS5fuAa9MOVDvXsT7Qa4v9Tg0Pk5ypfY3JWyW93a5sqyY2E2nCuRRBC53IikM9z0tVB2YYA8C9bWK8Lc47mATw==} @@ -785,7 +804,7 @@ packages: '@ethersproject/bignumber': 5.7.0 '@ethersproject/bytes': 5.7.0 '@ethersproject/constants': 5.7.0 - '@ethersproject/logger': 5.0.6 + '@ethersproject/logger': 5.7.0 '@ethersproject/properties': 5.7.0 '@ethersproject/transactions': 5.7.0 dev: true @@ -844,10 +863,6 @@ packages: '@ethersproject/bytes': 5.7.0 js-sha3: 0.8.0 - /@ethersproject/logger@5.0.6: - resolution: {integrity: sha512-FrX0Vnb3JZ1md/7GIZfmJ06XOAA8r3q9Uqt9O5orr4ZiksnbpXKlyDzQtlZ5Yv18RS8CAUbiKH9vwidJg1BPmQ==} - dev: true - /@ethersproject/logger@5.7.0: resolution: {integrity: sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==} @@ -1032,15 +1047,18 @@ packages: /@jridgewell/resolve-uri@3.1.2: resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} + dev: true /@jridgewell/sourcemap-codec@1.4.15: resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + dev: true /@jridgewell/trace-mapping@0.3.9: resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} dependencies: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.4.15 + dev: true /@manypkg/find-root@1.1.0: resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} @@ -1392,15 +1410,19 @@ packages: /@tsconfig/node10@1.0.11: resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==} + dev: true /@tsconfig/node12@1.0.11: resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} + dev: true /@tsconfig/node14@1.0.3: resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} + dev: true /@tsconfig/node16@1.0.4: resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} + dev: true /@types/async-eventemitter@0.2.4: resolution: {integrity: sha512-2Bq61VD01kgLf1XkK2xPtoBcu7fgn/km5JyEX9v0BlG5VQBzA+BlF9umFk+8gR8S4+eK7MgDY2oyVZCu6ar3Jw==} @@ -1701,11 +1723,13 @@ packages: /acorn-walk@8.3.2: resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} engines: {node: '>=0.4.0'} + dev: true /acorn@8.11.3: resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==} engines: {node: '>=0.4.0'} hasBin: true + dev: true /adm-zip@0.4.16: resolution: {integrity: sha512-TFi4HBKSGfIKsK5YCkKaaFG2m4PEDyViZmEwof3MTIgzimHLto6muaHVpbrljdIvIrFZzEq/p4nafOeLcYegrg==} @@ -3241,6 +3265,7 @@ packages: - c-kzg - supports-color - utf-8-validate + dev: true /hardhat@2.22.3(ts-node@9.1.1)(typescript@5.0.4): resolution: {integrity: sha512-k8JV2ECWNchD6ahkg2BR5wKVxY0OiKot7fuxiIpRK0frRqyOljcR2vKwgWSLw6YIeDcNNA4xybj7Og7NSxr2hA==} @@ -3304,7 +3329,6 @@ packages: - c-kzg - supports-color - utf-8-validate - dev: true /has-bigints@1.0.2: resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==} @@ -4817,6 +4841,7 @@ packages: typescript: 4.5.5 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 + dev: true /ts-node@9.1.1(typescript@5.0.4): resolution: {integrity: sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==} @@ -4832,7 +4857,6 @@ packages: source-map-support: 0.5.21 typescript: 5.0.4 yn: 3.1.1 - dev: true /tsconfig-paths@3.15.0: resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} @@ -4981,12 +5005,12 @@ packages: resolution: {integrity: sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==} engines: {node: '>=4.2.0'} hasBin: true + dev: true /typescript@5.0.4: resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} engines: {node: '>=12.20'} hasBin: true - dev: true /unbox-primitive@1.0.2: resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} @@ -5026,6 +5050,7 @@ packages: /v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} + dev: true /validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 2f2edb344..102fe76b1 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -2,3 +2,4 @@ packages: - "crates/edr_napi" - "crates/tools/js/benchmark" - "hardhat-tests" + - "hardhat-tests/integration/*" From a7a4ec171c250e04e1fe8d4d5d260f9f9951da8b Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Fri, 3 May 2024 11:26:38 +0200 Subject: [PATCH 15/18] Update lockfile --- pnpm-lock.yaml | 77 ++------------------------------------------------ 1 file changed, 2 insertions(+), 75 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3809359fd..aa8c76f91 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,15 +20,9 @@ importers: crates/edr_napi: devDependencies: - '@defi-wonderland/smock': - specifier: ^2.4.0 - version: 2.4.0(@ethersproject/abi@5.7.0)(@ethersproject/abstract-provider@5.7.0)(@ethersproject/abstract-signer@5.7.0)(@nomiclabs/hardhat-ethers@2.2.3)(ethers@5.7.2)(hardhat@2.22.3) '@napi-rs/cli': specifier: ^2.18.1 version: 2.18.1 - '@nomiclabs/hardhat-ethers': - specifier: ^2.2.3 - version: 2.2.3(ethers@5.7.2)(hardhat@2.22.3) '@types/chai': specifier: ^4.2.0 version: 4.3.12 @@ -47,9 +41,6 @@ importers: chai-as-promised: specifier: ^7.1.1 version: 7.1.1(chai@4.4.1) - hardhat: - specifier: ^2.22.3 - version: 2.22.3(ts-node@10.9.2)(typescript@4.5.5) mocha: specifier: ^10.0.0 version: 10.3.0 @@ -470,7 +461,7 @@ packages: '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.7.2)(hardhat@2.22.3) diff: 5.0.0 ethers: 5.7.2 - hardhat: 2.22.3(ts-node@10.9.2)(typescript@4.5.5) + hardhat: 2.22.3(ts-node@9.1.1)(typescript@5.0.4) lodash.isequal: 4.5.0 lodash.isequalwith: 4.4.0 rxjs: 7.8.1 @@ -1302,7 +1293,7 @@ packages: hardhat: ^2.0.0 dependencies: ethers: 5.7.2 - hardhat: 2.22.3(ts-node@10.9.2)(typescript@4.5.5) + hardhat: 2.22.3(ts-node@9.1.1)(typescript@5.0.4) dev: true /@scure/base@1.1.5: @@ -3203,70 +3194,6 @@ packages: engines: {node: '>=6'} dev: true - /hardhat@2.22.3(ts-node@10.9.2)(typescript@4.5.5): - resolution: {integrity: sha512-k8JV2ECWNchD6ahkg2BR5wKVxY0OiKot7fuxiIpRK0frRqyOljcR2vKwgWSLw6YIeDcNNA4xybj7Og7NSxr2hA==} - hasBin: true - peerDependencies: - ts-node: '*' - typescript: '*' - peerDependenciesMeta: - ts-node: - optional: true - typescript: - optional: true - dependencies: - '@ethersproject/abi': 5.7.0 - '@metamask/eth-sig-util': 4.0.1 - '@nomicfoundation/edr': link:crates/edr_napi - '@nomicfoundation/ethereumjs-common': 4.0.4 - '@nomicfoundation/ethereumjs-tx': 5.0.4 - '@nomicfoundation/ethereumjs-util': 9.0.4 - '@nomicfoundation/solidity-analyzer': 0.1.1 - '@sentry/node': 5.30.0 - '@types/bn.js': 5.1.5 - '@types/lru-cache': 5.1.1 - adm-zip: 0.4.16 - aggregate-error: 3.1.0 - ansi-escapes: 4.3.2 - boxen: 5.1.2 - chalk: 2.4.2 - chokidar: 3.6.0 - ci-info: 2.0.0 - debug: 4.3.4(supports-color@8.1.1) - enquirer: 2.4.1 - env-paths: 2.2.1 - ethereum-cryptography: 1.2.0 - ethereumjs-abi: 0.6.8 - find-up: 2.1.0 - fp-ts: 1.19.3 - fs-extra: 7.0.1 - glob: 7.2.0 - immutable: 4.3.5 - io-ts: 1.10.4 - keccak: 3.0.4 - lodash: 4.17.21 - mnemonist: 0.38.5 - mocha: 10.3.0 - p-map: 4.0.0 - raw-body: 2.5.2 - resolve: 1.17.0 - semver: 6.3.1 - solc: 0.7.3(debug@4.3.4) - source-map-support: 0.5.21 - stacktrace-parser: 0.1.10 - ts-node: 10.9.2(@types/node@18.15.13)(typescript@4.5.5) - tsort: 0.0.1 - typescript: 4.5.5 - undici: 5.28.3 - uuid: 8.3.2 - ws: 7.5.9 - transitivePeerDependencies: - - bufferutil - - c-kzg - - supports-color - - utf-8-validate - dev: true - /hardhat@2.22.3(ts-node@9.1.1)(typescript@5.0.4): resolution: {integrity: sha512-k8JV2ECWNchD6ahkg2BR5wKVxY0OiKot7fuxiIpRK0frRqyOljcR2vKwgWSLw6YIeDcNNA4xybj7Og7NSxr2hA==} hasBin: true From fa04e9a1a9f751d8334e3669a08e1bb5f612b516 Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Fri, 3 May 2024 11:45:59 +0200 Subject: [PATCH 16/18] Build EDR before running integration tests --- .github/workflows/hardhat-tests.yml | 2 +- hardhat-tests/package.json | 7 +++++-- hardhat-tests/run-integration-tests.sh | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/hardhat-tests.yml b/.github/workflows/hardhat-tests.yml index fc7ec183c..5ece4e182 100644 --- a/.github/workflows/hardhat-tests.yml +++ b/.github/workflows/hardhat-tests.yml @@ -65,7 +65,7 @@ jobs: DO_NOT_SET_THIS_ENV_VAR____IS_HARDHAT_CI: true FORCE_COLOR: 3 NODE_OPTIONS: --max-old-space-size=4096 - run: cd hardhat-tests && pnpm test + run: cd hardhat-tests && pnpm test:ci lint-hardhat-tests: name: Lint Hardhat tests runs-on: ubuntu-latest diff --git a/hardhat-tests/package.json b/hardhat-tests/package.json index 3e044842b..6cb9d3012 100644 --- a/hardhat-tests/package.json +++ b/hardhat-tests/package.json @@ -10,9 +10,12 @@ "lint:fix": "pnpm prettier --write && pnpm eslint --fix", "eslint": "eslint 'test/**/*.ts'", "prettier": "prettier \"**/*.{js,md,json}\"", - "pretest": "cd ../crates/edr_napi && pnpm build", - "test": "mocha --recursive \"test/**/*.ts\" && ./run-integration-tests.sh", + "pretest": "pnpm build:edr", + "test": "mocha --recursive \"test/**/*.ts\"", + "test:integration": "./run-integration-tests.sh", + "test:ci": "pnpm test && pnpm test:integration", "build": "tsc --build --force --incremental .", + "build:edr": "cd ../crates/edr_napi && pnpm build", "clean": "rimraf build-test tsconfig.tsbuildinfo test/internal/hardhat-network/provider/.hardhat_node_test_cache test/internal/hardhat-network/stack-traces/test-files/artifacts" }, "devDependencies": { diff --git a/hardhat-tests/run-integration-tests.sh b/hardhat-tests/run-integration-tests.sh index 44c5e7deb..11c1a3202 100755 --- a/hardhat-tests/run-integration-tests.sh +++ b/hardhat-tests/run-integration-tests.sh @@ -2,6 +2,8 @@ set -e +pnpm build:edr + cd integration for i in *; do if [ -d "$i" ]; then From 2df5d79f2154f7ca98417f33fd06720682e3480b Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Fri, 3 May 2024 11:51:14 +0200 Subject: [PATCH 17/18] Fix prettier --- hardhat-tests/integration/smock/hardhat.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardhat-tests/integration/smock/hardhat.config.js b/hardhat-tests/integration/smock/hardhat.config.js index 3ab0cb6fe..d9d9afc3b 100644 --- a/hardhat-tests/integration/smock/hardhat.config.js +++ b/hardhat-tests/integration/smock/hardhat.config.js @@ -1,4 +1,4 @@ -require("@nomiclabs/hardhat-ethers") +require("@nomiclabs/hardhat-ethers"); /** @type import('hardhat/config').HardhatUserConfig */ module.exports = { From cd9696407e890aaecdb80a59eabb8a14170cebdc Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Fri, 3 May 2024 14:36:44 +0200 Subject: [PATCH 18/18] Fix test:integration script on windows --- hardhat-tests/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardhat-tests/package.json b/hardhat-tests/package.json index 6cb9d3012..29d568755 100644 --- a/hardhat-tests/package.json +++ b/hardhat-tests/package.json @@ -12,7 +12,7 @@ "prettier": "prettier \"**/*.{js,md,json}\"", "pretest": "pnpm build:edr", "test": "mocha --recursive \"test/**/*.ts\"", - "test:integration": "./run-integration-tests.sh", + "test:integration": "bash run-integration-tests.sh", "test:ci": "pnpm test && pnpm test:integration", "build": "tsc --build --force --incremental .", "build:edr": "cd ../crates/edr_napi && pnpm build",