-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2817 from build-5/bugfix/missing_nft_credit
Credit tokens if nft was not sent
- Loading branch information
Showing
6 changed files
with
326 additions
and
154 deletions.
There are no files selected for viewing
184 changes: 110 additions & 74 deletions
184
.github/workflows/functions_tangle-online-unit-tests_emulator.yml
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/functions/test-tangle/nft-staking/nft-staking_10.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { build5Db } from '@build-5/database'; | ||
import { | ||
COL, | ||
MIN_IOTA_AMOUNT, | ||
Network, | ||
StakeType, | ||
Transaction, | ||
TransactionType, | ||
} from '@build-5/interfaces'; | ||
import { stakeNft } from '../../src/runtime/firebase/nft/index'; | ||
import { mockWalletReturnValue, wait } from '../../test/controls/common'; | ||
import { testEnv } from '../../test/set-up'; | ||
import { requestFundsFromFaucet } from '../faucet'; | ||
import { Helper } from './Helper'; | ||
|
||
describe('Collection minting', () => { | ||
const helper = new Helper(); | ||
|
||
beforeAll(async () => { | ||
await helper.beforeAll(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await helper.beforeEach(); | ||
}); | ||
|
||
it('Should return credits when nft deposit order does not receive nft', async () => { | ||
mockWalletReturnValue(helper.walletSpy, helper.guardian!, { | ||
network: Network.RMS, | ||
weeks: 25, | ||
type: StakeType.DYNAMIC, | ||
}); | ||
const order = await testEnv.wrap(stakeNft)({}); | ||
await requestFundsFromFaucet(Network.RMS, order.payload.targetAddress, MIN_IOTA_AMOUNT); | ||
|
||
const query = build5Db() | ||
.collection(COL.TRANSACTION) | ||
.where('type', '==', TransactionType.CREDIT) | ||
.where('member', '==', helper.guardian!); | ||
await wait(async () => { | ||
const snap = await query.get<Transaction>(); | ||
return ( | ||
snap.length === 1 && | ||
snap[0].payload.walletReference?.confirmed && | ||
snap[0].payload.amount === MIN_IOTA_AMOUNT | ||
); | ||
}); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
packages/functions/test-tangle/withdraw-deposit-nft/deposit-withraw-nft_16.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { build5Db } from '@build-5/database'; | ||
import { COL, MIN_IOTA_AMOUNT, Network, Transaction, TransactionType } from '@build-5/interfaces'; | ||
import { depositNft } from '../../src/runtime/firebase/nft/index'; | ||
import { mockWalletReturnValue, wait } from '../../test/controls/common'; | ||
import { testEnv } from '../../test/set-up'; | ||
import { requestFundsFromFaucet } from '../faucet'; | ||
import { Helper } from './Helper'; | ||
|
||
describe('Collection minting', () => { | ||
const helper = new Helper(); | ||
|
||
beforeAll(async () => { | ||
await helper.beforeAll(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await helper.beforeEach(); | ||
}); | ||
|
||
it('Should return credits when nft deposit order does not receive nft', async () => { | ||
mockWalletReturnValue(helper.walletSpy, helper.guardian!, { network: helper.network }); | ||
const order = await testEnv.wrap(depositNft)({}); | ||
await requestFundsFromFaucet(Network.RMS, order.payload.targetAddress, MIN_IOTA_AMOUNT); | ||
|
||
const query = build5Db() | ||
.collection(COL.TRANSACTION) | ||
.where('type', '==', TransactionType.CREDIT) | ||
.where('member', '==', helper.guardian!); | ||
await wait(async () => { | ||
const snap = await query.get<Transaction>(); | ||
return ( | ||
snap.length === 1 && | ||
snap[0].payload.walletReference?.confirmed && | ||
snap[0].payload.amount === MIN_IOTA_AMOUNT | ||
); | ||
}); | ||
}); | ||
}); |