Skip to content

Commit 904c903

Browse files
committed
Unit test for NFT withdraw
1 parent e9fca42 commit 904c903

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/tests/mintNFT.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let exchange: ExchangeAPI
3434

3535
// let nftTokenAddress = '0x662168Dc15F4D516bE7741f3BBC3592Ea9A6eDB5'
3636
//test should change the id number
37-
let nftId = '0x0000000000000000000000000000000000000000000000000000000000000099'
37+
let nftId = '0x0000000000000000000000000000000000000000000000000000000000000094'
3838
describe('Mint test', function () {
3939

4040
beforeEach(async () => {
@@ -71,7 +71,7 @@ describe('Mint test', function () {
7171
address: accInfo.owner,
7272
exchangeAddress: exchangeInfo.exchangeAddress,
7373
keyNonce: accInfo.nonce - 1,
74-
walletType: ConnectorNames.Unknown,
74+
walletType: ConnectorNames.MetaMask,
7575
}
7676
)
7777

@@ -82,7 +82,9 @@ describe('Mint test', function () {
8282
accountId: accInfo.accountId,
8383
}
8484

85-
const {apiKey} = await userApi.getUserApiKey(request, eddsakey.sk)
85+
let {apiKey} = await userApi.getUserApiKey(request, eddsakey.sk)
86+
apiKey = apiKey?? loopring_exported_account.apiKey;
87+
8688
console.log(apiKey)
8789
// step 4 get storageId
8890
const request2: GetNextStorageIdRequest = {
@@ -104,7 +106,7 @@ describe('Mint test', function () {
104106
nftId: nftId, //nftId.toString(16),
105107
amount: '500',
106108
validUntil: VALID_UNTIL,
107-
storageId: storageId.offchainId,
109+
storageId: storageId.offchainId??9,
108110
maxFee: {
109111
tokenId: 1,
110112
amount: '9400000000000000000',

src/tests/transferNFT.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('Transfer NFT test', function () {
9292
address: accInfo.owner,
9393
exchangeAddress: loopring_exported_account.exchangeAddr,
9494
keyNonce: accInfo.nonce - 1,
95-
walletType: ConnectorNames.Unknown,
95+
walletType: ConnectorNames.MetaMask,
9696
}
9797
)
9898

src/tests/withdrawNFT.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe('Withdraw NFT test', function () {
100100
address: accInfo.owner,
101101
exchangeAddress: loopring_exported_account.exchangeAddr,
102102
keyNonce: accInfo.nonce - 1,
103-
walletType: ConnectorNames.Unknown,
103+
walletType: ConnectorNames.MetaMask,
104104
}
105105
)
106106
console.log('eddsakey:', eddsaKey.sk)
@@ -110,22 +110,23 @@ describe('Withdraw NFT test', function () {
110110

111111
let { apiKey } = await userApi.getUserApiKey(request, eddsaKey.sk)
112112
apiKey = apiKey?? loopring_exported_account.apiKey;
113-
console.log(apiKey)
113+
console.log('apiKey',apiKey)
114+
114115
const request2: GetNextStorageIdRequest = {
115116
accountId: accInfo.accountId,
116117
sellTokenId: 1
117118
}
118119

119120
const storageId = await userApi.getNextStorageId(request2, apiKey);
120-
121+
console.log('storageId',storageId)
121122
const requestFee: GetNFTOffchainFeeAmtRequest = {
122123
accountId:accInfo.accountId,
123124
tokenAddress:loopring_exported_account.nftTokenAddress,
124125
requestType:OffchainNFTFeeReqType.NFT_WITHDRAWAL,
125126
amount:'0',
126127
}
127-
const responseFee = await userApi.getNFTOffchainFeeAmt(requestFee, apiKey)
128-
128+
const resultFee = await userApi.getNFTOffchainFeeAmt(requestFee, apiKey)
129+
console.log('requestFee',resultFee)
129130
const request3:NFTWithdrawRequestV3 = {
130131
minGas: 0,
131132
exchange: exchangeInfo.exchangeAddress,
@@ -140,7 +141,7 @@ describe('Withdraw NFT test', function () {
140141
extraData:'',
141142
maxFee: {
142143
tokenId: 1,
143-
amount: responseFee.fees[0]?.fee??'676000000000000000'
144+
amount: resultFee.fees[0]?.fee??'676000000000000000'
144145
},
145146
storageId: storageId?.offchainId??9,
146147
validUntil: 1667396982,
@@ -149,7 +150,7 @@ describe('Withdraw NFT test', function () {
149150
const response = await userApi.submitNFTWithdraw({
150151
request:request3,
151152
web3, chainId: ChainId.GOERLI,
152-
walletType: ConnectorNames.Unknown,
153+
walletType: ConnectorNames.Trezor,
153154
eddsaKey: eddsaKey.sk, apiKey})
154155
console.log('response:',response)
155156

0 commit comments

Comments
 (0)