Skip to content

Commit

Permalink
Make Block tests less fragile
Browse files Browse the repository at this point in the history
  • Loading branch information
dawsbot committed Sep 4, 2022
1 parent bc46618 commit 2d62def
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/classes/Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ export class BaseContract {
/**
* Applies the unique contract's methods to the instantiated Contract in the constructor based-upon the provided ABI
*
* @param object
* @param name
* @param value
* @internal
* @example
*/
export function defineReadOnly<T>(object: T, name: string, value: any): void {
Object.defineProperty(object, name, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ describe('provider.getBlockNumber', () => {
essentialEthProvider.getBlockNumber(),
ethersProvider.getBlockNumber(),
]);
expect(essentialEthBlockNumber).toStrictEqual(ethersBlockNumber);
// allow one-block flexibility because of timing of requests
expect(Math.abs(essentialEthBlockNumber - ethersBlockNumber)).toBeLessThan(
2,
);
});
it('should match web3.js', async () => {
const essentialEthProvider = new JsonRpcProvider(rpcUrl);
Expand Down

0 comments on commit 2d62def

Please sign in to comment.