Skip to content

Commit

Permalink
Add test to verify pending block extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylavrenov committed Jan 9, 2024
1 parent 8d66bed commit 5268b4f
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions utils/e2e-tests/ts/tests/rpc/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,39 @@ describe("eth rpc", () => {
});
});
});

describe("pending block", () => {
it("should return pending block", async function () {
const [alice, bob] = devSigners;

var nonce = 0;
// Prepare and send transaction from alice increasing nonce value.
let sendTransaction = async () => {
const tx =
{
from: alice,
to: bob,
value: ethers.parseEther("1"),
nonce: nonce,
};
nonce = nonce + 1;
return (await alice.sendTransaction(tx));
};

// Send enough transactions number to have some pending.
const expectedXtsNumber = 10;
for (var _ of Array(expectedXtsNumber)) {
await sendTransaction();
}

// Get pending block.
const pending = await provider.send("eth_getBlockByNumber", ["pending", false]);
expect(pending.hash).to.be.null;
expect(pending.miner).to.be.null;
expect(pending.nonce).to.be.null;
expect(pending.totalDifficulty).to.be.null;
// Check that there are some pending transactions.
expect(pending.transactions.length).toBeGreaterThan(0);
});
});
});

0 comments on commit 5268b4f

Please sign in to comment.