Files
xahau.js/test/models/paymentChannelFund.ts
Mayukha Vadari 91cc9e0461 Lints test/utils (#1575)
* rename model tests

* rename util tests

* turn off `any` complaints in linter

* other linter changes

* fix xrp <-> drops methods

* lint generateAddress

* fix rest of tests
2021-10-04 14:10:11 -04:00

86 lines
2.1 KiB
TypeScript

import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyPaymentChannelFund } from "../../src/models/transactions/paymentChannelFund";
/**
* PaymentChannelFund Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe("PaymentChannelFund", function () {
let channel;
beforeEach(function () {
channel = {
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
TransactionType: "PaymentChannelFund",
Channel:
"C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198",
Amount: "200000",
Expiration: 543171558,
};
});
it(`verifies valid PaymentChannelFund`, function () {
assert.doesNotThrow(() => verifyPaymentChannelFund(channel));
});
it(`verifies valid PaymentChannelFund w/o optional`, function () {
delete channel.Expiration;
assert.doesNotThrow(() => verifyPaymentChannelFund(channel));
});
it(`throws w/ missing Amount`, function () {
delete channel.Amount;
assert.throws(
() => verifyPaymentChannelFund(channel),
ValidationError,
"PaymentChannelFund: missing Amount"
);
});
it(`throws w/ missing Channel`, function () {
delete channel.Channel;
assert.throws(
() => verifyPaymentChannelFund(channel),
ValidationError,
"PaymentChannelFund: missing Channel"
);
});
it(`throws w/ invalid Amount`, function () {
channel.Amount = 100;
assert.throws(
() => verifyPaymentChannelFund(channel),
ValidationError,
"PaymentChannelFund: Amount must be a string"
);
});
it(`throws w/ invalid Channel`, function () {
channel.Channel = 1000;
assert.throws(
() => verifyPaymentChannelFund(channel),
ValidationError,
"PaymentChannelFund: Channel must be a string"
);
});
it(`throws w/ invalid Expiration`, function () {
channel.Expiration = "1000";
assert.throws(
() => verifyPaymentChannelFund(channel),
ValidationError,
"PaymentChannelFund: Expiration must be a number"
);
});
});