11import { loadFixture } from "@nomicfoundation/hardhat-network-helpers" ;
22import { expect } from "chai" ;
3+ import { constants } from "ethers" ;
34
45import { MockTimeLockVault } from "../../types" ;
56import { deployMockTimeLockVaultFixture } from "./time-lock-vault.fixture" ;
@@ -15,10 +16,37 @@ describe("Time-Lock Vault", () => {
1516 } ) ;
1617
1718 describe ( "Setup" , ( ) => {
18- it ( "should return the correct asset contract address" , async ( ) => {
19- const asset = await mockVaultContract . asset ( ) ;
19+ describe ( "When asset is specified" , ( ) => {
20+ it ( "should return the correct asset contract address" , async ( ) => {
21+ const asset = await mockVaultContract . asset ( ) ;
2022
21- expect ( asset ) . to . equal ( fixtures . mockERC20Contract . address ) ;
23+ expect ( asset ) . to . equal ( fixtures . mockERC20Contract . address ) ;
24+ } ) ;
25+
26+ it ( "should have the same decimals as asset contract" , async ( ) => {
27+ const decimals = await mockVaultContract . decimals ( ) ;
28+ const assetDecimals = await fixtures . mockERC20Contract . decimals ( ) ;
29+
30+ expect ( decimals ) . to . equal ( assetDecimals ) ;
31+ } ) ;
32+ } ) ;
33+
34+ describe ( "When asset is zero address" , ( ) => {
35+ beforeEach ( async ( ) => {
36+ await mockVaultContract
37+ . connect ( fixtures . signers . deployer )
38+ . setAssetInternal ( constants . AddressZero ) ;
39+
40+ // Assert that asset is zero address
41+ const asset = await mockVaultContract . asset ( ) ;
42+ expect ( asset ) . to . equal ( constants . AddressZero ) ;
43+ } ) ;
44+
45+ it ( "should revert when returning decimals" , async ( ) => {
46+ const tx = mockVaultContract . decimals ( ) ;
47+
48+ await expect ( tx ) . to . be . revertedWithCustomError ( mockVaultContract , "AssetUndefined" ) ;
49+ } ) ;
2250 } ) ;
2351 } ) ;
2452} ) ;
0 commit comments