@@ -20,7 +20,6 @@ describe("Test Leasing precompile", () => {
2020
2121 let wallet1 : ethers . Wallet ;
2222 let wallet2 : ethers . Wallet ;
23- let wallet3 : ethers . Wallet ;
2423 let leaseContract : ethers . Contract ;
2524 let crowdloanContract : ethers . Contract ;
2625 let neuronContract : ethers . Contract ;
@@ -34,22 +33,18 @@ describe("Test Leasing precompile", () => {
3433
3534 wallet1 = generateRandomEthersWallet ( ) ;
3635 wallet2 = generateRandomEthersWallet ( ) ;
37- wallet3 = generateRandomEthersWallet ( ) ;
3836 leaseContract = new ethers . Contract ( ILEASING_ADDRESS , ILeasingABI , wallet1 ) ;
3937 crowdloanContract = new ethers . Contract ( ICROWDLOAN_ADDRESS , ICrowdloanABI , wallet1 ) ;
4038 neuronContract = new ethers . Contract ( INEURON_ADDRESS , INeuronABI , wallet1 ) ;
4139
4240 await forceSetBalanceToEthAddress ( api , wallet1 . address ) ;
4341 await forceSetBalanceToEthAddress ( api , wallet2 . address ) ;
44- await forceSetBalanceToEthAddress ( api , wallet3 . address ) ;
45- await neuronContract . burnedRegister ( 1 , convertH160ToPublicKey ( wallet3 . address ) ) ;
46- await forceSetBalanceToEthAddress ( api , wallet1 . address ) ;
4742 } ) ;
4843
4944 it ( "gets an existing lease created on substrate side, its subnet id and its contributor shares" , async ( ) => {
5045 const nextCrowdloanId = await api . query . Crowdloan . NextCrowdloanId . getValue ( ) ;
5146 const crowdloanDeposit = BigInt ( 100_000_000_000 ) ; // 100 TAO
52- const crowdloanCap = BigInt ( 10_000_000_000_000 ) ; // 10000 TAO
47+ const crowdloanCap = await api . query . SubtensorModule . NetworkLastLockCost . getValue ( ) * BigInt ( 2 ) ;
5348 const crowdloanEnd = await api . query . System . Number . getValue ( ) + 100 ;
5449 const leaseEmissionsShare = 15 ;
5550 const leaseEnd = await api . query . System . Number . getValue ( ) + 300 ;
@@ -104,7 +99,7 @@ describe("Test Leasing precompile", () => {
10499 const nextCrowdloanId = await api . query . Crowdloan . NextCrowdloanId . getValue ( ) ;
105100 const crowdloanDeposit = BigInt ( 100_000_000_000 ) ; // 100 TAO
106101 const crowdloanMinContribution = BigInt ( 1_000_000_000 ) ; // 1 TAO
107- const crowdloanCap = BigInt ( 10_000_000_000_000 ) ; // 10000 TAO
102+ const crowdloanCap = await api . query . SubtensorModule . NetworkLastLockCost . getValue ( ) * BigInt ( 2 ) ;
108103 const crowdloanEnd = await api . query . System . Number . getValue ( ) + 100 ;
109104 const leasingEmissionsShare = 15 ;
110105 const leasingEndBlock = await api . query . System . Number . getValue ( ) + 300 ;
@@ -158,15 +153,19 @@ describe("Test Leasing precompile", () => {
158153 } ) ;
159154
160155 it ( "terminates a lease" , async ( ) => {
156+ const hotkey = generateRandomEthersWallet ( ) ;
157+ let tx = await neuronContract . burnedRegister ( 1 , convertH160ToPublicKey ( hotkey . address ) ) ;
158+ await tx . wait ( ) ;
159+
161160 const nextCrowdloanId = await api . query . Crowdloan . NextCrowdloanId . getValue ( ) ;
162161 const crowdloanDeposit = BigInt ( 100_000_000_000 ) ; // 100 TAO
163162 const crowdloanMinContribution = BigInt ( 1_000_000_000 ) ; // 1 TAO
164- const crowdloanCap = BigInt ( 10_000_000_000_000 ) ; // 10000 TAO
163+ const crowdloanCap = await api . query . SubtensorModule . NetworkLastLockCost . getValue ( ) * BigInt ( 2 ) ;
165164 const crowdloanEnd = await api . query . System . Number . getValue ( ) + 100 ;
166165 const leasingEmissionsShare = 15 ;
167166 const leasingEndBlock = await api . query . System . Number . getValue ( ) + 200 ;
168167
169- let tx = await leaseContract . createLeaseCrowdloan (
168+ tx = await leaseContract . createLeaseCrowdloan (
170169 crowdloanDeposit ,
171170 crowdloanMinContribution ,
172171 crowdloanCap ,
@@ -193,7 +192,7 @@ describe("Test Leasing precompile", () => {
193192 assert . isDefined ( lease ) ;
194193 const netuid = lease . netuid ;
195194
196- tx = await leaseContract . terminateLease ( nextLeaseId , convertH160ToPublicKey ( wallet3 . address ) ) ;
195+ tx = await leaseContract . terminateLease ( nextLeaseId , convertH160ToPublicKey ( hotkey . address ) ) ;
197196 await tx . wait ( ) ;
198197
199198 lease = await api . query . SubtensorModule . SubnetLeases . getValue ( nextLeaseId ) ;
@@ -203,6 +202,6 @@ describe("Test Leasing precompile", () => {
203202 const ownerColdkey = await api . query . SubtensorModule . SubnetOwner . getValue ( netuid ) ;
204203 const ownerHotkey = await api . query . SubtensorModule . SubnetOwnerHotkey . getValue ( netuid ) ;
205204 assert . equal ( ownerColdkey , convertH160ToSS58 ( wallet1 . address ) ) ;
206- assert . equal ( ownerHotkey , convertH160ToSS58 ( wallet3 . address ) ) ;
205+ assert . equal ( ownerHotkey , convertH160ToSS58 ( hotkey . address ) ) ;
207206 } ) ;
208207} )
0 commit comments