Created
December 1, 2020 04:08
-
-
Save tms1337/a391665661f357aca6a62e9e4d8b0275 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
| // function | |
| import createFilterTransactions from "../functions/filterTransactions"; | |
| // fake services | |
| import { createFakeGetAddresses } from "../services/argent/getAddresses"; | |
| import { createFakeGetTransactionsForBlock } from "../services/eth/getTransactionsForBlock"; | |
| describe("filterTransactions", () => { | |
| it("correctly filters transactions", async (done) => { | |
| const transactions = [ | |
| { txHash: "0x1", from: "0x1234", to: "0x123", value: "0x1" }, | |
| { txHash: "0x2", from: "0x1234", to: "0x123", value: "0x2" }, | |
| { txHash: "0x3", from: "0x1234", to: "0x122", value: "0x3" }, | |
| { txHash: "0x4", from: "0x1234", to: "0x122", value: "0x4" }, | |
| ]; | |
| const getTransactionsForBlock = createFakeGetTransactionsForBlock({ | |
| transactions, | |
| }); | |
| const argentAddresses = ["0x123"]; | |
| const getAddresses = createFakeGetAddresses({ | |
| addressess: argentAddresses, | |
| }); | |
| const filterTransactions = createFilterTransactions({ | |
| getTransactionsForBlock, | |
| getAddresses, | |
| }); | |
| const result = await filterTransactions({ blockNumber: 123 }); | |
| const expectedOutput = [ | |
| { txHash: "0x1", from: "0x1234", to: "0x123", value: "0x1" }, | |
| { txHash: "0x2", from: "0x1234", to: "0x123", value: "0x2" }, | |
| ]; | |
| expect(expectedOutput).toEqual(result); | |
| done(); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment