This repository was archived by the owner on Jun 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
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
6dc0375
commit 03544d1
Showing
10 changed files
with
148 additions
and
115 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as React from 'react'; | ||
import AssetsTable from './AssetsTable'; | ||
import renderWithProviders from '@/__utils__/renderWithProviders'; | ||
|
||
describe(`AssetsTable`, () => { | ||
it(`should render the assets table`, () => { | ||
const { container } = renderWithProviders(<AssetsTable assets={[]} />); | ||
expect(container).toBeDefined(); | ||
}); | ||
}); |
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,12 @@ | ||
import * as React from 'react'; | ||
import MySwapsTable from './MySwapsTable'; | ||
import renderWithProviders from '@/__utils__/renderWithProviders'; | ||
|
||
describe(`MySwapsTable`, () => { | ||
it(`should render the assets table`, () => { | ||
const { container } = renderWithProviders( | ||
<MySwapsTable swapConfigurations={[]} />, | ||
); | ||
expect(container).toBeDefined(); | ||
}); | ||
}); |
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,18 @@ | ||
import * as React from 'react'; | ||
import renderWithProviders from '@/__utils__/renderWithProviders'; | ||
import PublicSwapAssetsTable from './PublicSwapAssetsTable'; | ||
import { ChainType } from '@/models/Chain'; | ||
import { IpfsGateway } from '@/models/Gateway'; | ||
|
||
describe(`PublicSwapAssetsTable`, () => { | ||
it(`should render the assets table`, () => { | ||
const { container } = renderWithProviders( | ||
<PublicSwapAssetsTable | ||
address="test" | ||
gateway={IpfsGateway.ALGONODE_IO} | ||
chain={ChainType.TestNet} | ||
/>, | ||
); | ||
expect(container).toBeDefined(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ChainType } from '@/models/Chain'; | ||
import { SwapConfiguration } from '@/models/Swap'; | ||
import getSwapUrl from './getSwapUrl'; | ||
|
||
describe(`getSwapUrl`, () => { | ||
it(`should return the correct URL for a mainnet swap`, () => { | ||
const swapConfiguration = { | ||
proxy: `proxy-address`, | ||
escrow: `escrow-address`, | ||
}; | ||
const chain = ChainType.MainNet; | ||
|
||
const result = getSwapUrl(swapConfiguration as SwapConfiguration, chain); | ||
|
||
expect(result).toBe( | ||
`${window.location.origin}/swap/proxy-address/escrow-address?chain=mainnet`, | ||
); | ||
}); | ||
|
||
it(`should return the correct URL for a testnet swap`, () => { | ||
const swapConfiguration = { | ||
proxy: `proxy-address`, | ||
escrow: `escrow-address`, | ||
}; | ||
const chain = ChainType.TestNet; | ||
|
||
const result = getSwapUrl(swapConfiguration as SwapConfiguration, chain); | ||
|
||
expect(result).toBe( | ||
`${window.location.origin}/swap/proxy-address/escrow-address?chain=testnet`, | ||
); | ||
}); | ||
}); |
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,18 @@ | ||
import saveSwapConfigurations from './saveSwapConfigurations'; | ||
import axios from 'axios'; | ||
import { SwapConfiguration } from '@/models/Swap'; | ||
|
||
jest.mock(`axios`); | ||
|
||
test(`saveSwapConfigurations sends a POST request to the correct URL with the correct data`, async () => { | ||
const configurations = [{ foo: `bar` }, { baz: `qux` }]; | ||
const expectedUrl = `/api/storage/save-configurations`; | ||
|
||
// Call the function that we are testing | ||
await saveSwapConfigurations( | ||
configurations as unknown as SwapConfiguration[], | ||
); | ||
|
||
// Assert that axios.post was called with the correct arguments | ||
expect(axios.post).toHaveBeenCalledWith(expectedUrl, configurations); | ||
}); |
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 { ChainType } from '@/models/Chain'; | ||
import { TransactionToSign, TransactionToSignType } from '@/models/Transaction'; | ||
import algosdk, { generateAccount, LogicSigAccount } from 'algosdk'; | ||
import { algodForChain } from '../algorand'; | ||
|
||
import processTransactions from './processTransactions'; | ||
|
||
describe(`processTransactions`, () => { | ||
it(`should process and sign a transaction`, async () => { | ||
// Create a transaction object | ||
const tempAddress = generateAccount(); | ||
const suggestedParams = await algodForChain(`testnet` as ChainType) | ||
.getTransactionParams() | ||
.do(); | ||
const transaction: TransactionToSign = { | ||
transaction: algosdk.makePaymentTxnWithSuggestedParams( | ||
tempAddress.addr, | ||
tempAddress.addr, | ||
0, | ||
undefined, | ||
undefined, | ||
suggestedParams, | ||
), | ||
type: TransactionToSignType.UserFeeTransaction, | ||
signer: `addr` as unknown as LogicSigAccount, | ||
}; | ||
// Process the transaction | ||
const signTransactions = jest.fn().mockImplementation(() => { | ||
return { | ||
catch: (error: any) => { | ||
console.error(error); | ||
return []; | ||
}, | ||
}; | ||
}); | ||
|
||
const signedTransactions = await processTransactions( | ||
[transaction], | ||
signTransactions, | ||
); | ||
// Expect the signed version of the transaction to be returned (0x01 instead of 0x00 as the first byte) | ||
expect(signedTransactions).toEqual([]); | ||
}); | ||
}); |
03544d1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for algoworld-swapper ready!
✅ Preview
https://algoworld-swapper-4zh5m7scr-algoworldexplorer.vercel.app
Built with commit 03544d1.
This pull request is being automatically deployed with vercel-action