@@ -12,6 +12,7 @@ const BLOCK_NUMBER = "42";
1212const CALL_RET = "call_ret" ;
1313const GAS_USED = "87654" ;
1414const TX_HASH = "transactionHash" ;
15+ const nowInSec = Math . floor ( Date . now ( ) / 1000 ) ;
1516
1617test ( "imports EthersAdapter" , ( ) => {
1718 expect ( EthersAdapter ) . toBeTruthy ( ) ;
@@ -24,15 +25,15 @@ test("EthersAdapter constructor", () => {
2425 expect ( ethersAdapter ) . toBeTruthy ( ) ;
2526} ) ;
2627
27- test ( "EthConnectAdapter getSignerAddress without signer" , async ( ) => {
28+ test ( "EthersAdapter getSignerAddress without signer" , async ( ) => {
2829 const provider = mockProvider ( ) ;
2930 const ethersAdapter = new EthersAdapter ( provider ) ;
3031 expect ( ethersAdapter ) . toBeTruthy ( ) ;
3132 const signerAddress = await ethersAdapter . getSignerAddress ( ) ;
3233 expect ( signerAddress ) . toEqual ( WALLETS [ 0 ] ) ;
3334} ) ;
3435
35- test ( "EthConnectAdapter getSignerAddress with signer" , async ( ) => {
36+ test ( "EthersAdapter getSignerAddress with signer" , async ( ) => {
3637 const provider = mockProvider ( ) ;
3738 const signer = mockSigner ( WALLETS [ 2 ] ) ;
3839 const ethersAdapter = new EthersAdapter ( provider , signer ) ;
@@ -41,6 +42,14 @@ test("EthConnectAdapter getSignerAddress with signer", async () => {
4142 expect ( signerAddress ) . toEqual ( WALLETS [ 2 ] ) ;
4243} ) ;
4344
45+ test ( "EthersAdapter getCurrentTimeMs" , async ( ) => {
46+ const provider = mockProvider ( ) ;
47+ const ethersAdapter = new EthersAdapter ( provider ) ;
48+ expect ( ethersAdapter ) . toBeTruthy ( ) ;
49+ const nowMs = await ethersAdapter . getCurrentTimeMs ( ) ;
50+ expect ( nowMs ) . toBe ( nowInSec * 1000 ) ; // Convert seconds to milliseconds
51+ } ) ;
52+
4453function mockProvider ( ) : Provider {
4554 return {
4655 getBalance : async ( ) => {
@@ -58,7 +67,8 @@ function mockProvider(): Provider {
5867 } ,
5968 send : async ( ) => TX_HASH ,
6069 getSigner : ( ) => mockSigner ( WALLETS [ 0 ] ) ,
61- getCode : async ( ) => "0x"
70+ getCode : async ( ) => "0x" ,
71+ getBlock : async ( ) => ( { timestamp : nowInSec } )
6272 } as unknown as Provider ;
6373}
6474
@@ -67,8 +77,5 @@ function mockSigner(wallet: string): Signer {
6777 getAddress : async ( ) => wallet ,
6878 getChainId : async ( ) => CHAIN_ID
6979 } ;
70- return {
71- ...signer ,
72- connect : ( ) => signer
73- } as unknown as Signer ;
80+ return { ...signer , connect : ( ) => signer } as unknown as Signer ;
7481}
0 commit comments