2020-06-30 15:37:35 -07:00
|
|
|
/**
|
|
|
|
* Exercises the token-swap program
|
|
|
|
*
|
|
|
|
* @flow
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {
|
|
|
|
loadPrograms,
|
2020-11-17 08:54:55 -08:00
|
|
|
createAccountAndSwapAtomic,
|
2020-07-01 00:56:00 -07:00
|
|
|
createTokenSwap,
|
2020-06-30 15:37:35 -07:00
|
|
|
swap,
|
2020-12-16 01:02:27 -08:00
|
|
|
depositAllTokenTypes,
|
|
|
|
withdrawAllTokenTypes,
|
|
|
|
depositSingleTokenTypeExactAmountIn,
|
|
|
|
withdrawSingleTokenTypeExactAmountOut,
|
2020-06-30 15:37:35 -07:00
|
|
|
} from './token-swap-test';
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
// These test cases are designed to run sequentially and in the following order
|
2020-07-01 00:56:00 -07:00
|
|
|
console.log('Run test: loadPrograms');
|
2020-06-30 15:37:35 -07:00
|
|
|
await loadPrograms();
|
2020-07-01 00:56:00 -07:00
|
|
|
console.log('Run test: createTokenSwap');
|
|
|
|
await createTokenSwap();
|
2020-12-16 01:02:27 -08:00
|
|
|
console.log('Run test: deposit all token types');
|
|
|
|
await depositAllTokenTypes();
|
|
|
|
console.log('Run test: withdraw all token types');
|
|
|
|
await withdrawAllTokenTypes();
|
2020-06-30 15:37:35 -07:00
|
|
|
console.log('Run test: swap');
|
|
|
|
await swap();
|
2020-11-17 08:54:55 -08:00
|
|
|
console.log('Run test: create account, approve, swap all at once');
|
|
|
|
await createAccountAndSwapAtomic();
|
2020-12-16 01:02:27 -08:00
|
|
|
console.log('Run test: deposit one exact amount in');
|
|
|
|
await depositSingleTokenTypeExactAmountIn();
|
|
|
|
console.log('Run test: withrdaw one exact amount out');
|
|
|
|
await withdrawSingleTokenTypeExactAmountOut();
|
2020-06-30 15:37:35 -07:00
|
|
|
console.log('Success\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|
|
|
|
.catch(err => {
|
|
|
|
console.error(err);
|
2020-07-07 13:55:56 -07:00
|
|
|
process.exit(-1);
|
2020-06-30 15:37:35 -07:00
|
|
|
})
|
|
|
|
.then(() => process.exit());
|