test enforcing trade limit over grpc

This commit is contained in:
woodser 2022-12-15 21:39:43 +00:00
parent 5d21478642
commit 28d119c681

View File

@ -1104,7 +1104,7 @@ test("Can create crypto payment accounts (CI)", async () => {
}); });
test("Can prepare for trading (CI)", async () => { test("Can prepare for trading (CI)", async () => {
await prepareForTrading(4, user1, user2); await prepareForTrading(5, user1, user2);
}); });
test("Can post and remove an offer (CI)", async () => { test("Can post and remove an offer (CI)", async () => {
@ -1255,6 +1255,16 @@ test("Can schedule offers with locked funds (CI)", async () => {
if (err) throw err; if (err) throw err;
}); });
test("Cannot post offer exceeding trade limit (CI)", async () => {
const revolutAccount = await createRevolutPaymentAccount(user1);
try {
await executeTrade({amount: BigInt("2100000000000"), assetCode: "USD", makerPaymentAccountId: revolutAccount.getId(), takeOffer: false});
throw new Error("Should have rejected posting offer above trade limit")
} catch (err) {
assert(err.message.indexOf("amount is larger than") === 0);
}
});
test("Can complete a trade", async () => { test("Can complete a trade", async () => {
await executeTrade(); await executeTrade();
}); });
@ -3058,7 +3068,7 @@ function testCryptoPaymentAccountsEqual(acct1: PaymentAccount, acct2: PaymentAcc
expect(acct1.getPaymentAccountPayload()!.getCryptoCurrencyAccountPayload()!.getAddress()).toEqual(acct2.getPaymentAccountPayload()!.getCryptoCurrencyAccountPayload()!.getAddress()); expect(acct1.getPaymentAccountPayload()!.getCryptoCurrencyAccountPayload()!.getAddress()).toEqual(acct2.getPaymentAccountPayload()!.getCryptoCurrencyAccountPayload()!.getAddress());
} }
function testOffer(offer: OfferInfo, config?: any) { function testOffer(offer: OfferInfo, config?: TradeContext) {
expect(offer.getId().length).toBeGreaterThan(0); expect(offer.getId().length).toBeGreaterThan(0);
if (config) { if (config) {
expect(HavenoUtils.centinerosToAtomicUnits(offer.getAmount())).toEqual(config.amount); // TODO (woodser): use atomic units in offer instead of centineros? expect(HavenoUtils.centinerosToAtomicUnits(offer.getAmount())).toEqual(config.amount); // TODO (woodser): use atomic units in offer instead of centineros?