-
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.
Fix soon claim with multiple addresses
Fixes Fixes
- Loading branch information
Boldizsar Mezei
committed
May 10, 2024
1 parent
6a7597a
commit b330aab
Showing
6 changed files
with
171 additions
and
70 deletions.
There are no files selected for viewing
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
12 changes: 10 additions & 2 deletions
12
...ctions/src/services/payment/tangle-service/buildcore-token/VerifyEthForB5TangleRequest.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
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
83 changes: 83 additions & 0 deletions
83
packages/functions/test-tangle/soon_snap/soon.snap.claim.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,83 @@ | ||
import { database } from '@buildcore/database'; | ||
import { | ||
COL, | ||
MIN_IOTA_AMOUNT, | ||
Network, | ||
TangleRequestType, | ||
Transaction, | ||
} from '@buildcore/interfaces'; | ||
import { getRandomEthAddress } from '../../src/utils/wallet.utils'; | ||
import { wait } from '../../test/controls/common'; | ||
import { getWallet } from '../../test/set-up'; | ||
import { getTangleOrder } from '../common'; | ||
import { requestFundsFromFaucet } from '../faucet'; | ||
|
||
describe('Soon snapshot claim', () => { | ||
let tangleOrder: Transaction; | ||
|
||
beforeAll(async () => { | ||
tangleOrder = await getTangleOrder(Network.RMS); | ||
}); | ||
|
||
it('Claim soon snap with single eth address', async () => { | ||
const wallet = await getWallet(Network.RMS); | ||
const address = await wallet.getNewIotaAddressDetails(); | ||
|
||
await requestFundsFromFaucet(Network.RMS, address.bech32, MIN_IOTA_AMOUNT); | ||
|
||
const ethAddress = ['0x69252ebdc3b77624c6e640a81a086aaa720734d3']; | ||
|
||
const soonSnaps = [ | ||
{ uid: address.bech32, count: 12, paidOut: 0, ethAddress: '', ethAddressVerified: false }, | ||
]; | ||
await database().getCon()(COL.SOON_SNAP).insert(soonSnaps); | ||
|
||
await wallet.send(address, tangleOrder.payload.targetAddress!, MIN_IOTA_AMOUNT, { | ||
customMetadata: { | ||
request: { | ||
requestType: TangleRequestType.VERIFY_ETH_ADDRESS, | ||
ethAddress: ethAddress.join(','), | ||
}, | ||
}, | ||
}); | ||
|
||
await wait(async () => { | ||
const soonSnaps = await database().collection(COL.SOON_SNAP).whereIn('uid', ethAddress).get(); | ||
return soonSnaps.reduce((acc, act) => acc && act.ethAddressVerified, true); | ||
}); | ||
}); | ||
|
||
it('Claim soon snap with multiple eth address', async () => { | ||
const wallet = await getWallet(Network.RMS); | ||
const address = await wallet.getNewIotaAddressDetails(); | ||
|
||
await requestFundsFromFaucet(Network.RMS, address.bech32, MIN_IOTA_AMOUNT); | ||
|
||
const ethAddress = [ | ||
'0x69252ebdc3b77624c6e640a81a086aaa720734d3', | ||
getRandomEthAddress(), | ||
getRandomEthAddress(), | ||
]; | ||
|
||
const soonSnaps = [ | ||
{ uid: address.bech32, count: 12, paidOut: 0, ethAddress: '', ethAddressVerified: false }, | ||
{ uid: ethAddress[1], count: 12, paidOut: 0, ethAddress: '', ethAddressVerified: false }, | ||
{ uid: ethAddress[2], count: 12, paidOut: 0, ethAddress: '', ethAddressVerified: false }, | ||
]; | ||
await database().getCon()(COL.SOON_SNAP).insert(soonSnaps); | ||
|
||
await wallet.send(address, tangleOrder.payload.targetAddress!, MIN_IOTA_AMOUNT, { | ||
customMetadata: { | ||
request: { | ||
requestType: TangleRequestType.VERIFY_ETH_ADDRESS, | ||
ethAddress: ethAddress.join(','), | ||
}, | ||
}, | ||
}); | ||
|
||
await wait(async () => { | ||
const soonSnaps = await database().collection(COL.SOON_SNAP).whereIn('uid', ethAddress).get(); | ||
return soonSnaps.reduce((acc, act) => acc && act.ethAddressVerified, true); | ||
}); | ||
}); | ||
}); |