From 8b053a9af290a1d669477cdfb11c22b52dbe3d8d Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Wed, 5 Jul 2023 15:37:27 +0300 Subject: [PATCH] Adding additional test --- test/integration/FixedRateExchange.test.ts | 68 +++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/test/integration/FixedRateExchange.test.ts b/test/integration/FixedRateExchange.test.ts index e5774a5..26b4e56 100644 --- a/test/integration/FixedRateExchange.test.ts +++ b/test/integration/FixedRateExchange.test.ts @@ -94,7 +94,7 @@ describe('Fixed Rate Exchange tests', async () => { cap, feeAmount, paymentCollector: ZERO_ADDRESS, - feeToken: addresses.MockUSDC.toLowerCase(), + feeToken: ZERO_ADDRESS, minter: publisher, mpFeeAddress: marketPlaceFeeAddress } @@ -198,6 +198,72 @@ describe('Fixed Rate Exchange tests', async () => { ) }) + it('Deploying a Fixed Rate Exchange with USDC as feeToken', async () => { + const usdcSwapFee = '1' + + const nftParams: NftCreateData = { + name: nftName, + symbol: nftSymbol, + templateIndex: 1, + tokenURI, + transferable: true, + owner: publisher + } + const erc20Params: DatatokenCreateParams = { + templateIndex, + cap, + feeAmount, + paymentCollector: ZERO_ADDRESS, + feeToken: addresses.MockUSDC, // Testing if the decimals are correct when using USDC as the feeToken + minter: publisher, + mpFeeAddress: marketPlaceFeeAddress + } + const fixedRateParams: FreCreationParams = { + fixedRateAddress, + baseTokenAddress, + owner: publisher, + marketFeeCollector: marketPlaceFeeAddress, + baseTokenDecimals: 18, + datatokenDecimals: 18, + fixedRate: price, + marketFee: usdcSwapFee, + allowedConsumer: ZERO_ADDRESS, + withMint: false + } + + const result = await Factory.createNftWithDatatokenWithFixedRate( + publisher, + nftParams, + erc20Params, + fixedRateParams + ) + + const secondDatatokenAddress = + result.events.TokenCreated.returnValues[0].toLowerCase() + + const dtQuery = { + query: `query { + token(id: "${secondDatatokenAddress}"){ + publishMarketFeeAddress, + publishMarketFeeAmount + }}` + } + const dtResponse = await fetch(subgraphUrl, { + method: 'POST', + body: JSON.stringify(dtQuery) + }) + const secondDt = (await dtResponse.json()).data.token + + assert(secondDt, 'No datatoken') + console.log('publishMarketFeeAmount', dt.publishMarketFeeAmount) + console.log('usdcSwapFee', usdcSwapFee) + + assert( + dt.publishMarketFeeAmount === usdcSwapFee, + 'incorrect value for: publishMarketFeeAmount' + ) + }) + it('Test DT Fields after deploying Fixed rate exchange', async () => { // Check Datatoken Values const dtQuery = {