-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9e2acd
commit b83d641
Showing
9 changed files
with
203 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
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,62 @@ | ||
import { mock, resetMocks } from '@depay/web3-mock' | ||
import { request, provider, resetCache } from 'src/' | ||
import { struct, publicKey, u64, u32, u8, PublicKey, Buffer } from '@depay/solana-web3.js' | ||
import { supported } from 'src/blockchains' | ||
|
||
describe('request getProgramAccounts', () => { | ||
|
||
supported.solana.forEach((blockchain)=>{ | ||
|
||
describe(blockchain, ()=> { | ||
|
||
const accounts = ['2UgCJaHU5y8NC4uWQcZYeV9a5RyYLF7iKYCybCsdFFD1'] | ||
beforeEach(resetMocks) | ||
beforeEach(resetCache) | ||
beforeEach(()=>mock({ blockchain, accounts: { return: accounts } })) | ||
|
||
it('requests getProgramAccounts with given filters', async ()=> { | ||
|
||
let wallet = '2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9' | ||
let mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' | ||
|
||
let filters = [ | ||
{ dataSize: 165 }, | ||
{ memcmp: { offset: 32, bytes: wallet }}, | ||
{ memcmp: { offset: 0, bytes: mint }} | ||
] | ||
|
||
let requestMock = mock({ | ||
provider: provider(blockchain), | ||
blockchain, | ||
request: { | ||
method: 'getProgramAccounts', | ||
to: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', | ||
params: { filters }, | ||
return: [ | ||
{ | ||
account: { data: new Buffer([]), executable: false, lamports: 2039280, owner: mint, rentEpoch: 327 }, | ||
pubkey: '3JdKXacGdntfNKXzSGC2EwUDKFPrXdsqowbuc9hEiNBb' | ||
}, { | ||
account: { data: new Buffer([]), executable: false, lamports: 2039280, owner: mint, rentEpoch: 327 }, | ||
pubkey: 'FjtHL8ki3GXMhCqY2Lum9CCAv5tSQMkhJEnXbEkajTrZ' | ||
}, { | ||
account: { data: new Buffer([]), executable: false, lamports: 2039280, owner: mint, rentEpoch: 327 }, | ||
pubkey: 'F7e4iBrxoSmHhEzhuBcXXs1KAknYvEoZWieiocPvrCD9' | ||
} | ||
] | ||
} | ||
}) | ||
|
||
let accounts = await request('solana://TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA/getProgramAccounts', { | ||
params: { filters } | ||
}) | ||
|
||
expect(accounts.map((account)=>account.pubkey.toString())).toEqual([ | ||
'3JdKXacGdntfNKXzSGC2EwUDKFPrXdsqowbuc9hEiNBb', | ||
'FjtHL8ki3GXMhCqY2Lum9CCAv5tSQMkhJEnXbEkajTrZ', | ||
'F7e4iBrxoSmHhEzhuBcXXs1KAknYvEoZWieiocPvrCD9' | ||
]) | ||
}) | ||
}) | ||
}) | ||
}) |
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,44 @@ | ||
import { mock, resetMocks } from '@depay/web3-mock' | ||
import { request, provider, resetCache } from 'src/' | ||
import { struct, publicKey, u64, u32, u8, PublicKey, Buffer } from '@depay/solana-web3.js' | ||
import { supported } from 'src/blockchains' | ||
|
||
describe('request getTokenAccountBalance', () => { | ||
|
||
supported.solana.forEach((blockchain)=>{ | ||
|
||
describe(blockchain, ()=> { | ||
|
||
const accounts = ['2UgCJaHU5y8NC4uWQcZYeV9a5RyYLF7iKYCybCsdFFD1'] | ||
beforeEach(resetMocks) | ||
beforeEach(resetCache) | ||
beforeEach(()=>mock({ blockchain, accounts: { return: accounts } })) | ||
|
||
it('requests getTokenAccountBalance with given filters', async ()=> { | ||
|
||
let tokenAccount = '2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9' | ||
|
||
let returnedBalance = { | ||
amount: "10000617", | ||
decimals: 6, | ||
uiAmount: 10.000617, | ||
uiAmountString: "10.000617" | ||
} | ||
|
||
let requestMock = mock({ | ||
provider: provider(blockchain), | ||
blockchain, | ||
request: { | ||
method: 'getTokenAccountBalance', | ||
to: tokenAccount, | ||
return: returnedBalance | ||
} | ||
}) | ||
|
||
let balance = await request(`solana://${tokenAccount}/getTokenAccountBalance`) | ||
|
||
expect(balance.value).toEqual(returnedBalance) | ||
}) | ||
}) | ||
}) | ||
}) |
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