@@ -23,7 +23,7 @@ import {
2323 USER_1_IDENTITY_WALLET_V1
2424} from '../Fixtures'
2525
26- import { MetaTransaction } from '../../src/typings'
26+ import { MetaTransaction , NonceMechanism } from '../../src/typings'
2727import {
2828 calculateIdentityAddress ,
2929 getRandomNonce ,
@@ -43,10 +43,13 @@ describe('unit', () => {
4343
4444 const init = ( ) => {
4545 fakeTLProvider = new FakeTLProvider ( )
46- identityWallet = new IdentityWallet ( fakeTLProvider , FAKE_CHAIN_ID , {
47- identityFactoryAddress : IDENTITY_FACTORY_ADDRESS ,
48- identityImplementationAddress : IDENTITY_IMPLEMENTATION_ADDRESS
49- } )
46+ identityWallet = new IdentityWallet (
47+ fakeTLProvider ,
48+ FAKE_CHAIN_ID ,
49+ IDENTITY_FACTORY_ADDRESS ,
50+ IDENTITY_IMPLEMENTATION_ADDRESS ,
51+ NonceMechanism . Random
52+ )
5053 }
5154
5255 describe ( '#create()' , ( ) => {
@@ -230,6 +233,34 @@ describe('unit', () => {
230233 )
231234 } )
232235 } )
236+
237+ describe ( '#getNonce' , ( ) => {
238+ beforeEach ( ( ) => init ( ) )
239+
240+ it ( 'should generate nonce with random mechanism' , async ( ) => {
241+ const randomIdentityWallet = new IdentityWallet (
242+ fakeTLProvider ,
243+ FAKE_CHAIN_ID ,
244+ IDENTITY_FACTORY_ADDRESS ,
245+ IDENTITY_IMPLEMENTATION_ADDRESS ,
246+ NonceMechanism . Random
247+ )
248+ assert . isString ( await randomIdentityWallet . getNonce ( ) )
249+ } )
250+
251+ it ( 'should generate nonce with counting mechanism' , async ( ) => {
252+ const countingIdentityWallet = new IdentityWallet (
253+ fakeTLProvider ,
254+ FAKE_CHAIN_ID ,
255+ IDENTITY_FACTORY_ADDRESS ,
256+ IDENTITY_IMPLEMENTATION_ADDRESS ,
257+ NonceMechanism . Counting
258+ )
259+ const walletData = await countingIdentityWallet . create ( )
260+ await countingIdentityWallet . loadFrom ( walletData )
261+ assert . isString ( await countingIdentityWallet . getNonce ( ) )
262+ } )
263+ } )
233264 } )
234265
235266 describe ( '#getRandomNonce' , ( ) => {
0 commit comments