Skip to content

Commit

Permalink
test(credentials): mock tests in the blockchain transactions validator
Browse files Browse the repository at this point in the history
  • Loading branch information
vplasencia committed Jan 31, 2024
1 parent 5895260 commit 9c69049
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { providers } from "ethers"
import { validateCredentials } from "../.."
import blockchainTransactions from "./index"

describe("BlockchainTransactions", () => {
const rpcUrl = "http://example.com"
const jsonRpcProviderMocked = {
getTransactionCount: jest.fn()
}

it("Should return true if an account has greater than or equal to 10 transactions", async () => {
jsonRpcProviderMocked.getTransactionCount.mockReturnValue(12)

// eslint-disable-next-line
it.skip("Should return true if an account has greater than or equal to 10 transactions", async () => {
const result = await validateCredentials(
{
id: blockchainTransactions.id,
Expand All @@ -16,25 +18,28 @@ describe("BlockchainTransactions", () => {
},
{
address: "0x",
jsonRpcProvider: new providers.JsonRpcProvider(rpcUrl)
jsonRpcProvider: {
getTransactionCount: jest.fn().mockResolvedValue(12)
}
}
)

expect(result).toBeTruthy()
})

// eslint-disable-next-line
it.skip("Should return true if an account has greater than or equal to 10 transactions using the block number", async () => {
it("Should return true if an account has greater than or equal to 10 transactions using the block number", async () => {
jsonRpcProviderMocked.getTransactionCount.mockReturnValue(12)

const result = await validateCredentials(
{
id: blockchainTransactions.id,
criteria: {
minTransactions: 46
minTransactions: 10
}
},
{
address: "0x",
jsonRpcProvider: new providers.JsonRpcProvider(rpcUrl),
jsonRpcProvider: jsonRpcProviderMocked,
blockNumber: 4749638
}
)
Expand Down

0 comments on commit 9c69049

Please sign in to comment.