Skip to content

Commit

Permalink
e2e test assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith committed Apr 15, 2024
1 parent f8a2a13 commit 97387d0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/chains/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { queryGasPrice } from "../utils/gasPrice";
import { buildTxPayload, addSignature } from "../utils/transaction";

export class NearEthAdapter {
private ethClient: PublicClient;
ethClient: PublicClient;
private scanUrl: string;
private gasStationUrl: string;

Expand Down Expand Up @@ -196,7 +196,6 @@ export class NearEthAdapter {
private async relaySignedTransaction(
serializedTransaction: Hex
): Promise<Hash> {
// const serializedTransaction = serializeTransaction(signedTx);
const txHash = await this.ethClient.sendRawTransaction({
serializedTransaction,
});
Expand Down
30 changes: 25 additions & 5 deletions tests/e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
import { setupNearEthAdapter } from "../examples/setup";
import { NearEthAdapter } from "../src";
import { getBalance } from "viem/actions";

describe("End To End", () => {
let evm: NearEthAdapter;
const to = "0xdeADBeeF0000000000000000000000000b00B1e5";
const ONE_WEI = 1n;

beforeAll(async () => {
evm = await setupNearEthAdapter();
});

afterAll(async () => {
clearTimeout();
});

it("Runs the Send ETH Tx", async () => {
const evm = await setupNearEthAdapter();
await evm.signAndSendTransaction({
to: "0xdeADBeeF0000000000000000000000000b00B1e5",
// THIS IS ONE WEI!
value: 1n,
await expect(
evm.signAndSendTransaction({ to, value: ONE_WEI })
).resolves.not.toThrow();
});

it("Fails Invalid Send ETH Tx", async () => {
const senderBalance = await getBalance(evm.ethClient, {
address: evm.ethPublicKey(),
});
await expect(
evm.signAndSendTransaction({ to, value: senderBalance + ONE_WEI })
).rejects.toThrow();
});
});

0 comments on commit 97387d0

Please sign in to comment.