@@ -24,6 +24,8 @@ describe("Test Leasing precompile", () => {
2424 let leaseContract : ethers . Contract ;
2525 let crowdloanContract : ethers . Contract ;
2626 let neuronContract : ethers . Contract ;
27+ const crowdloanDeposit = BigInt ( 100_000_000_000 ) ;
28+ let crowdloanCap : bigint ;
2729
2830 const alice = getAliceSigner ( ) ;
2931 const bob = getBobSigner ( ) ;
@@ -42,12 +44,17 @@ describe("Test Leasing precompile", () => {
4244 await forceSetBalanceToEthAddress ( api , wallet2 . address ) ;
4345
4446 await resetNetworkLastLock ( api ) ;
47+ const minLockCost = await api . query . SubtensorModule . NetworkMinLockCost . getValue ( ) ;
48+ // guarantee that the crowdloan cap is larger than the deposit
49+ if ( minLockCost > crowdloanDeposit ) {
50+ crowdloanCap = minLockCost * BigInt ( 2 ) ;
51+ } else {
52+ crowdloanCap = crowdloanDeposit * BigInt ( 2 ) ;
53+ }
4554 } ) ;
4655
4756 it ( "gets an existing lease created on substrate side, its subnet id and its contributor shares" , async ( ) => {
4857 const nextCrowdloanId = await api . query . Crowdloan . NextCrowdloanId . getValue ( ) ;
49- const crowdloanDeposit = BigInt ( 100_000_000_000 ) ; // 100 TAO
50- const crowdloanCap = await api . query . SubtensorModule . NetworkLastLockCost . getValue ( ) * BigInt ( 10 ) ;
5158 const crowdloanEnd = await api . query . System . Number . getValue ( ) + 100 ;
5259 const leaseEmissionsShare = 15 ;
5360 const leaseEnd = await api . query . System . Number . getValue ( ) + 300 ;
@@ -69,8 +76,8 @@ describe("Test Leasing precompile", () => {
6976 amount : crowdloanCap - crowdloanDeposit ,
7077 } ) . signAndSubmit ( bob ) ;
7178
72- await waitForFinalizedBlock ( api , crowdloanEnd ) ;
7379
80+ await waitForFinalizedBlock ( api , crowdloanEnd ) ;
7481 const nextLeaseId = await api . query . SubtensorModule . NextSubnetLeaseId . getValue ( ) ;
7582 await api . tx . Crowdloan . finalize ( { crowdloan_id : nextCrowdloanId } ) . signAndSubmit ( alice ) ;
7683
@@ -100,9 +107,7 @@ describe("Test Leasing precompile", () => {
100107
101108 it ( "registers a new leased network through a crowdloan and retrieves the lease" , async ( ) => {
102109 const nextCrowdloanId = await api . query . Crowdloan . NextCrowdloanId . getValue ( ) ;
103- const crowdloanDeposit = BigInt ( 100_000_000_000 ) ; // 100 TAO
104110 const crowdloanMinContribution = BigInt ( 1_000_000_000 ) ; // 1 TAO
105- const crowdloanCap = await api . query . SubtensorModule . NetworkLastLockCost . getValue ( ) * BigInt ( 10 ) ;
106111 const crowdloanEnd = await api . query . System . Number . getValue ( ) + 100 ;
107112 const leasingEmissionsShare = 15 ;
108113 const leasingEndBlock = await api . query . System . Number . getValue ( ) + 300 ;
@@ -161,9 +166,7 @@ describe("Test Leasing precompile", () => {
161166 await tx . wait ( ) ;
162167
163168 const nextCrowdloanId = await api . query . Crowdloan . NextCrowdloanId . getValue ( ) ;
164- const crowdloanDeposit = BigInt ( 100_000_000_000 ) ; // 100 TAO
165169 const crowdloanMinContribution = BigInt ( 1_000_000_000 ) ; // 1 TAO
166- const crowdloanCap = await api . query . SubtensorModule . NetworkLastLockCost . getValue ( ) * BigInt ( 10 ) ;
167170 const crowdloanEnd = await api . query . System . Number . getValue ( ) + 100 ;
168171 const leasingEmissionsShare = 15 ;
169172 const leasingEndBlock = await api . query . System . Number . getValue ( ) + 200 ;
0 commit comments