-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cancel Orders #73
Cancel Orders #73
Conversation
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.
Implementation seems ok. Request to add test cases concerning cancelling orders for swaps in dexes.
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.
You can add some tests cases here (and for all the others dexes similarly):
I created locally 2 scenarios for cancelling orders (Success & Failure) for minswap, you can do the same for the other dexs.
I write the snippet of code below so you can add them:
import {
UTxO
} from '@app/types';
then under describe
describe('Minswap', () => {
let minswap: Minswap;
const returnAddress = 'mockBlockchainAddress123';
beforeEach(() => {
minswap = new Minswap();
});
// rest of the code as it is and add below:
describe('Minswap Cancel Order Flow', () => {
it('should successfully cancel an order', async () => {
let marketOrderAddress = minswap.marketOrderAddress;
const txOutputs: UTxO[] = [
{
txHash: 'mockTxHash123',
address: marketOrderAddress,
datumHash: 'mockDatumHash123',
outputIndex: 0,
assetBalances: [{ asset: 'lovelace', quantity: 1000000000000n }]
}
];
const result = await minswap.buildCancelSwapOrder(txOutputs, returnAddress);
expect(result).toBeDefined();
expect(result[0].address).toBe(returnAddress);
});
it('should fail to cancel an order with invalid UTxO', async () => {
const invalidTxOutputs: UTxO[] = [
{
txHash: 'invalidTxHash',
address: 'invalidAddress',
datumHash: 'invalidDatumHash',
outputIndex: 0,
assetBalances: [{ asset: 'lovelace', quantity: 1000n }]
}
];
try {
await minswap.buildCancelSwapOrder(invalidTxOutputs, returnAddress);
fail('Expected buildCancelSwapOrder to throw an error');
} catch (error: unknown) {
if (error instanceof Error) {
expect(error.message).toContain('Unable to find relevant UTxO for cancelling the swap order.');
}
}
});
});
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.
I created a PR for Tests regarding Cancel Orders, so you don't need to add on this PR.
PR is ok for me.
No description provided.