Skip to content

Commit

Permalink
Run tests using JsonRpcProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
keyz-tk committed May 25, 2023
1 parent 338b5ca commit bd4c2ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion examples/with-ethers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ async function main() {

// Bring your own provider (such as Alchemy or Infura: https://docs.ethers.org/v5/api/providers/)
const network = "goerli";
const provider = new ethers.providers.InfuraProvider(network);
const provider = new ethers.providers.JsonRpcProvider(
"https://goerli.infura.io/v3/84842078b09946638c03157f83405213", // using the default community project
network
);
const connectedSigner = turnkeySigner.connect(provider);

const chainId = await connectedSigner.getChainId();
Expand Down
12 changes: 8 additions & 4 deletions packages/ethers/src/__tests__/index-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Eip1193Bridge } from "@ethersproject/experimental";
import { setBalance } from "@nomicfoundation/hardhat-network-helpers";
import { ethers } from "ethers";
import hre from "hardhat";
import { test, expect, beforeEach, describe } from "@jest/globals";
Expand Down Expand Up @@ -60,8 +59,10 @@ describe("TurnkeySigner", () => {
`process.env.BANNED_TO_ADDRESS`
);

// @ts-ignore
const provider = hre.ethers.provider;
const provider = new ethers.providers.JsonRpcProvider(
hre.config.networks.localhost.url,
hre.config.networks.localhost.chainId
);

connectedSigner = new TurnkeySigner({
apiPublicKey,
Expand All @@ -75,7 +76,10 @@ describe("TurnkeySigner", () => {

eip1193 = new Eip1193Bridge(connectedSigner, provider);

setBalance(expectedEthAddress, ethers.utils.parseEther("999999"));
await provider.send("hardhat_setBalance", [
expectedEthAddress,
"0xffffffffffffffffffffffff",
]);
});

testCase("basics", async () => {
Expand Down

0 comments on commit bd4c2ba

Please sign in to comment.