build: Initial linting setup (#1560)

* sets up linting config and runs `yarn lint --fix` once, so that all changes will show up correctly in future PRs.

* Note that there are still a lot of linter errors.
This commit is contained in:
Nathan Nichols
2021-08-26 21:22:40 -05:00
committed by Mayukha Vadari
parent 12cfed5c17
commit 8b95ee5fab
286 changed files with 15508 additions and 12691 deletions

View File

@@ -1,78 +1,77 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyAccountDelete } from './../../src/models/transactions/accountDelete'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyAccountDelete } from "../../src/models/transactions/accountDelete";
/**
* AccountDelete Transaction Verification Testing
* AccountDelete Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('AccountDelete Transaction Verification', function () {
it (`verifies valid AccountDelete`, () => {
const validAccountDelete = {
TransactionType: "AccountDelete",
Account: "rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm",
Destination: "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
DestinationTag: 13,
Fee: "5000000",
Sequence: 2470665,
Flags: 2147483648
} as any
assert.doesNotThrow(() => verifyAccountDelete(validAccountDelete))
})
describe("AccountDelete Transaction Verification", function () {
it(`verifies valid AccountDelete`, function () {
const validAccountDelete = {
TransactionType: "AccountDelete",
Account: "rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm",
Destination: "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
DestinationTag: 13,
Fee: "5000000",
Sequence: 2470665,
Flags: 2147483648,
} as any;
assert.doesNotThrow(() => verifyAccountDelete(validAccountDelete));
});
it (`throws w/ missing Destination`, () => {
const invalidDestination = {
TransactionType: "AccountDelete",
Account: "rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm",
Fee: "5000000",
Sequence: 2470665,
Flags: 2147483648
} as any
it(`throws w/ missing Destination`, function () {
const invalidDestination = {
TransactionType: "AccountDelete",
Account: "rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm",
Fee: "5000000",
Sequence: 2470665,
Flags: 2147483648,
} as any;
assert.throws(
() => verifyAccountDelete(invalidDestination),
ValidationError,
"AccountDelete: missing field Destination"
)
})
assert.throws(
() => verifyAccountDelete(invalidDestination),
ValidationError,
"AccountDelete: missing field Destination"
);
});
it (`throws w/ invalid Destination`, () => {
const invalidDestination = {
TransactionType: "AccountDelete",
Account: "rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm",
Destination: 65478965,
Fee: "5000000",
Sequence: 2470665,
Flags: 2147483648
} as any
it(`throws w/ invalid Destination`, function () {
const invalidDestination = {
TransactionType: "AccountDelete",
Account: "rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm",
Destination: 65478965,
Fee: "5000000",
Sequence: 2470665,
Flags: 2147483648,
} as any;
assert.throws(
() => verifyAccountDelete(invalidDestination),
ValidationError,
"AccountDelete: invalid Destination"
)
})
assert.throws(
() => verifyAccountDelete(invalidDestination),
ValidationError,
"AccountDelete: invalid Destination"
);
});
it (`throws w/ invalid DestinationTag`, () => {
const invalidDestinationTag = {
TransactionType: "AccountDelete",
Account: "rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm",
Destination: "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
DestinationTag: "gvftyujnbv",
Fee: "5000000",
Sequence: 2470665,
Flags: 2147483648
} as any
it(`throws w/ invalid DestinationTag`, function () {
const invalidDestinationTag = {
TransactionType: "AccountDelete",
Account: "rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm",
Destination: "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
DestinationTag: "gvftyujnbv",
Fee: "5000000",
Sequence: 2470665,
Flags: 2147483648,
} as any;
assert.throws(
() => verifyAccountDelete(invalidDestinationTag),
ValidationError,
"AccountDelete: invalid DestinationTag"
)
})
})
assert.throws(
() => verifyAccountDelete(invalidDestinationTag),
ValidationError,
"AccountDelete: invalid DestinationTag"
);
});
});

View File

@@ -1,110 +1,111 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyAccountSet } from './../../src/models/transactions/accountSet'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyAccountSet } from "../../src/models/transactions/accountSet";
/**
* AccountSet Transaction Verification Testing
* AccountSet Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('AccountSet Transaction Verification', function () {
describe("AccountSet Transaction Verification", function () {
let account;
let account
beforeEach(function () {
account = {
TransactionType: "AccountSet",
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Fee: "12",
Sequence: 5,
Domain: "6578616D706C652E636F6D",
SetFlag: 5,
MessageKey:
"03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB",
} as any;
});
beforeEach(() => {
account = {
TransactionType : "AccountSet",
Account : "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Fee : "12",
Sequence : 5,
Domain : "6578616D706C652E636F6D",
SetFlag : 5,
MessageKey : "03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB"
} as any
})
it(`verifies valid AccountSet`, function () {
assert.doesNotThrow(() => verifyAccountSet(account));
});
it (`verifies valid AccountSet`, () => {
assert.doesNotThrow(() => verifyAccountSet(account))
})
it(`throws w/ invalid SetFlag (out of range)`, function () {
account.SetFlag = 12;
it (`throws w/ invalid SetFlag (out of range)`, () => {
account.SetFlag = 12
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid SetFlag"
);
});
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid SetFlag"
)
})
it(`throws w/ invalid SetFlag (incorrect type)`, function () {
account.SetFlag = "abc";
it (`throws w/ invalid SetFlag (incorrect type)`, () => {
account.SetFlag = 'abc'
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid SetFlag"
)
})
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid SetFlag"
);
});
it (`throws w/ invalid ClearFlag`, () => {
account.ClearFlag = 12
it(`throws w/ invalid ClearFlag`, function () {
account.ClearFlag = 12;
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid ClearFlag"
)
})
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid ClearFlag"
);
});
it (`throws w/ invalid Domain`, () => {
account.Domain = 6578616
it(`throws w/ invalid Domain`, function () {
account.Domain = 6578616;
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid Domain"
)
})
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid Domain"
);
});
it (`throws w/ invalid EmailHash`, () => {
account.EmailHash = 657861645678909876543456789876543
it(`throws w/ invalid EmailHash`, function () {
account.EmailHash = 657861645678909876543456789876543;
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid EmailHash"
)
})
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid EmailHash"
);
});
it (`throws w/ invalid MessageKey`, () => {
account.MessageKey = 65786165678908765456789567890678
it(`throws w/ invalid MessageKey`, function () {
account.MessageKey = 65786165678908765456789567890678;
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid MessageKey"
)
})
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid MessageKey"
);
});
it (`throws w/ invalid TransferRate`, () => {
account.TransferRate = "1000000001"
it(`throws w/ invalid TransferRate`, function () {
account.TransferRate = "1000000001";
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid TransferRate"
)
})
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid TransferRate"
);
});
it (`throws w/ invalid TickSize`, () => {
account.TickSize = 20
it(`throws w/ invalid TickSize`, function () {
account.TickSize = 20;
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid TickSize"
)
})
})
assert.throws(
() => verifyAccountSet(account),
ValidationError,
"AccountSet: invalid TickSize"
);
});
});

View File

@@ -1,225 +1,232 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyBaseTransaction } from './../../src/models/transactions/common'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyBaseTransaction } from "../../src/models/transactions/common";
/**
* Transaction Verification Testing
* Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('Transaction Verification', function () {
it(`Verifies all optional BaseTransaction`, () => {
const txJson = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Fee: "12",
Sequence: 100,
AccountTxnID: "DEADBEEF",
Flags: 15,
LastLedgerSequence: 1383,
Memos: [
{
Memo: {
MemoType: "687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963",
MemoData: "72656e74"
}
},
{
Memo: {
MemoFormat: "687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963",
MemoData: "72656e74"
}
},
{
Memo: {
MemoType: "72656e74"
}
}
],
Signers: [
{
Account: "r....",
TxnSignature: "DEADBEEF",
SigningPubKey: "hex-string"
}
],
SourceTag: 31,
SigningPublicKey: "03680DD274EE55594F7244F489CD38CF3A5A1A4657122FB8143E185B2BA043DF36",
TicketSequence: 10,
TxnSignature: "3045022100C6708538AE5A697895937C758E99A595B57A16393F370F11B8D4C032E80B532002207776A8E85BB9FAF460A92113B9C60F170CD964196B1F084E0DAB65BAEC368B66"
}
describe("Transaction Verification", function () {
it(`Verifies all optional BaseTransaction`, function () {
const txJson = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Fee: "12",
Sequence: 100,
AccountTxnID: "DEADBEEF",
Flags: 15,
LastLedgerSequence: 1383,
Memos: [
{
Memo: {
MemoType:
"687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963",
MemoData: "72656e74",
},
},
{
Memo: {
MemoFormat:
"687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963",
MemoData: "72656e74",
},
},
{
Memo: {
MemoType: "72656e74",
},
},
],
Signers: [
{
Account: "r....",
TxnSignature: "DEADBEEF",
SigningPubKey: "hex-string",
},
],
SourceTag: 31,
SigningPublicKey:
"03680DD274EE55594F7244F489CD38CF3A5A1A4657122FB8143E185B2BA043DF36",
TicketSequence: 10,
TxnSignature:
"3045022100C6708538AE5A697895937C758E99A595B57A16393F370F11B8D4C032E80B532002207776A8E85BB9FAF460A92113B9C60F170CD964196B1F084E0DAB65BAEC368B66",
};
assert.doesNotThrow(() => verifyBaseTransaction(txJson))
})
assert.doesNotThrow(() => verifyBaseTransaction(txJson));
});
it(`Verifies only required BaseTransaction`, () => {
const txJson = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
}
assert.doesNotThrow(() => verifyBaseTransaction(txJson))
})
it(`Verifies only required BaseTransaction`, function () {
const txJson = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
};
it (`Handles invalid Fee`, () => {
const invalidFee = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Fee: 1000
} as any
assert.doesNotThrow(() => verifyBaseTransaction(txJson));
});
assert.throws(
() => verifyBaseTransaction(invalidFee),
ValidationError,
"BaseTransaction: invalid Fee"
)
})
it(`Handles invalid Fee`, function () {
const invalidFee = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Fee: 1000,
} as any;
it (`Handles invalid Sequence`, () => {
const invalidSeq = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Sequence: "145"
} as any
assert.throws(
() => verifyBaseTransaction(invalidFee),
ValidationError,
"BaseTransaction: invalid Fee"
);
});
assert.throws(
() => verifyBaseTransaction(invalidSeq),
ValidationError,
"BaseTransaction: invalid Sequence"
)
})
it(`Handles invalid Sequence`, function () {
const invalidSeq = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Sequence: "145",
} as any;
it (`Handles invalid AccountTxnID`, () => {
const invalidID = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
AccountTxnID: ["WRONG"]
} as any
assert.throws(
() => verifyBaseTransaction(invalidSeq),
ValidationError,
"BaseTransaction: invalid Sequence"
);
});
assert.throws(
() => verifyBaseTransaction(invalidID),
ValidationError,
"BaseTransaction: invalid AccountTxnID"
)
})
it(`Handles invalid AccountTxnID`, function () {
const invalidID = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
AccountTxnID: ["WRONG"],
} as any;
it (`Handles invalid LastLedgerSequence`, () => {
const invalidLastLedgerSequence = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
LastLedgerSequence: "1000"
} as any
assert.throws(
() => verifyBaseTransaction(invalidID),
ValidationError,
"BaseTransaction: invalid AccountTxnID"
);
});
assert.throws(
() => verifyBaseTransaction(invalidLastLedgerSequence),
ValidationError,
"BaseTransaction: invalid LastLedgerSequence"
)
})
it(`Handles invalid LastLedgerSequence`, function () {
const invalidLastLedgerSequence = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
LastLedgerSequence: "1000",
} as any;
it (`Handles invalid SourceTag`, () => {
const invalidSourceTag = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
SourceTag: ["ARRAY"]
} as any
assert.throws(
() => verifyBaseTransaction(invalidLastLedgerSequence),
ValidationError,
"BaseTransaction: invalid LastLedgerSequence"
);
});
assert.throws(
() => verifyBaseTransaction(invalidSourceTag),
ValidationError,
"BaseTransaction: invalid SourceTag"
)
})
it(`Handles invalid SourceTag`, function () {
const invalidSourceTag = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
SourceTag: ["ARRAY"],
} as any;
it (`Handles invalid SigningPubKey`, () => {
const invalidSigningPubKey = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
SigningPubKey: 1000
} as any
assert.throws(
() => verifyBaseTransaction(invalidSourceTag),
ValidationError,
"BaseTransaction: invalid SourceTag"
);
});
assert.throws(
() => verifyBaseTransaction(invalidSigningPubKey),
ValidationError,
"BaseTransaction: invalid SigningPubKey"
)
})
it(`Handles invalid SigningPubKey`, function () {
const invalidSigningPubKey = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
SigningPubKey: 1000,
} as any;
it (`Handles invalid TicketSequence`, () => {
const invalidTicketSequence = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
TicketSequence: "1000"
} as any
assert.throws(
() => verifyBaseTransaction(invalidSigningPubKey),
ValidationError,
"BaseTransaction: invalid SigningPubKey"
);
});
assert.throws(
() => verifyBaseTransaction(invalidTicketSequence),
ValidationError,
"BaseTransaction: invalid TicketSequence"
)
})
it(`Handles invalid TicketSequence`, function () {
const invalidTicketSequence = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
TicketSequence: "1000",
} as any;
it (`Handles invalid TxnSignature`, () => {
const invalidTxnSignature = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
TxnSignature: 1000
} as any
assert.throws(
() => verifyBaseTransaction(invalidTxnSignature),
ValidationError,
"BaseTransaction: invalid TxnSignature"
)
})
assert.throws(
() => verifyBaseTransaction(invalidTicketSequence),
ValidationError,
"BaseTransaction: invalid TicketSequence"
);
});
it (`Handles invalid Signers`, () => {
const invalidSigners = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Signers: []
} as any
it(`Handles invalid TxnSignature`, function () {
const invalidTxnSignature = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
TxnSignature: 1000,
} as any;
assert.throws(
() => verifyBaseTransaction(invalidSigners),
ValidationError,
"BaseTransaction: invalid Signers"
)
assert.throws(
() => verifyBaseTransaction(invalidTxnSignature),
ValidationError,
"BaseTransaction: invalid TxnSignature"
);
});
const invalidSigners2 = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Signers: [
{
"Account": "r...."
}
]
} as any
it(`Handles invalid Signers`, function () {
const invalidSigners = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Signers: [],
} as any;
assert.throws(
() => verifyBaseTransaction(invalidSigners2),
ValidationError,
"BaseTransaction: invalid Signers"
)
})
assert.throws(
() => verifyBaseTransaction(invalidSigners),
ValidationError,
"BaseTransaction: invalid Signers"
);
it (`Handles invalid Memo`, () => {
const invalidMemo = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Memos: [{
Memo: {
MemoData: "HI",
Address: "WRONG"
}
}]
} as any
const invalidSigners2 = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Signers: [
{
Account: "r....",
},
],
} as any;
assert.throws(
() => verifyBaseTransaction(invalidMemo),
ValidationError,
"BaseTransaction: invalid Memos"
)
})
})
assert.throws(
() => verifyBaseTransaction(invalidSigners2),
ValidationError,
"BaseTransaction: invalid Signers"
);
});
it(`Handles invalid Memo`, function () {
const invalidMemo = {
Account: "r97KeayHuEsDwyU1yPBVtMLLoQr79QcRFe",
TransactionType: "Payment",
Memos: [
{
Memo: {
MemoData: "HI",
Address: "WRONG",
},
},
],
} as any;
assert.throws(
() => verifyBaseTransaction(invalidMemo),
ValidationError,
"BaseTransaction: invalid Memos"
);
});
});

View File

@@ -1,35 +1,37 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyCheckCancel} from './../../src/models/transactions/checkCancel'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyCheckCancel } from "../../src/models/transactions/checkCancel";
/**
* CheckCancel Transaction Verification Testing
* CheckCancel Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('CheckCancel Transaction Verification', function () {
describe("CheckCancel Transaction Verification", function () {
it(`verifies valid CheckCancel`, function () {
const validCheckCancel = {
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
TransactionType: "CheckCancel",
CheckID:
"49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0",
} as any;
it (`verifies valid CheckCancel`, () => {
const validCheckCancel = {
Account : "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
TransactionType : "CheckCancel",
CheckID : "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0"
} as any
assert.doesNotThrow(() => verifyCheckCancel(validCheckCancel));
});
assert.doesNotThrow(() => verifyCheckCancel(validCheckCancel))
})
it(`throws w/ invalid CheckCancel`, function () {
const invalidCheckID = {
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
TransactionType: "CheckCancel",
CheckID: 496473456789876545678909876545678,
} as any;
it (`throws w/ invalid CheckCancel`, () => {
const invalidCheckID = {
Account : "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
TransactionType : "CheckCancel",
CheckID : 496473456789876545678909876545678
} as any
assert.throws(
() => verifyCheckCancel(invalidCheckID),
ValidationError,
"CheckCancel: invalid CheckID"
)
})
})
assert.throws(
() => verifyCheckCancel(invalidCheckID),
ValidationError,
"CheckCancel: invalid CheckID"
);
});
});

View File

@@ -1,84 +1,89 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyCheckCash } from './../../src/models/transactions/checkCash'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyCheckCash } from "../../src/models/transactions/checkCash";
/**
* CheckCash Transaction Verification Testing
* CheckCash Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('CheckCash Transaction Verification', function () {
it (`verifies valid CheckCash`, () => {
const validCheckCash = {
Account : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType : "CheckCash",
Amount : "100000000",
CheckID : "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334",
Fee : "12"
} as any
assert.doesNotThrow(() => verifyCheckCash(validCheckCash))
})
describe("CheckCash Transaction Verification", function () {
it(`verifies valid CheckCash`, function () {
const validCheckCash = {
Account: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType: "CheckCash",
Amount: "100000000",
CheckID:
"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334",
Fee: "12",
} as any;
it (`throws w/ invalid CheckID`, () => {
const invalidCheckID = {
Account : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType : "CheckCash",
Amount : "100000000",
CheckID : 83876645678909854567890
} as any
assert.doesNotThrow(() => verifyCheckCash(validCheckCash));
});
assert.throws(
() => verifyCheckCash(invalidCheckID),
ValidationError,
"CheckCash: invalid CheckID"
)
})
it(`throws w/ invalid CheckID`, function () {
const invalidCheckID = {
Account: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType: "CheckCash",
Amount: "100000000",
CheckID: 83876645678909854567890,
} as any;
it (`throws w/ invalid Amount`, () => {
const invalidAmount = {
Account : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType : "CheckCash",
Amount : 100000000,
CheckID : "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
} as any
assert.throws(
() => verifyCheckCash(invalidCheckID),
ValidationError,
"CheckCash: invalid CheckID"
);
});
assert.throws(
() => verifyCheckCash(invalidAmount),
ValidationError,
"CheckCash: invalid Amount"
)
})
it(`throws w/ invalid Amount`, function () {
const invalidAmount = {
Account: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType: "CheckCash",
Amount: 100000000,
CheckID:
"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334",
} as any;
it (`throws w/ having both Amount and DeliverMin`, () => {
const invalidDeliverMin = {
Account : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType : "CheckCash",
Amount : "100000000",
DeliverMin: 852156963,
CheckID : "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
} as any
assert.throws(
() => verifyCheckCash(invalidAmount),
ValidationError,
"CheckCash: invalid Amount"
);
});
assert.throws(
() => verifyCheckCash(invalidDeliverMin),
ValidationError,
"CheckCash: cannot have both Amount and DeliverMin"
)
})
it(`throws w/ having both Amount and DeliverMin`, function () {
const invalidDeliverMin = {
Account: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType: "CheckCash",
Amount: "100000000",
DeliverMin: 852156963,
CheckID:
"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334",
} as any;
it (`throws w/ invalid DeliverMin`, () => {
const invalidDeliverMin = {
Account : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType : "CheckCash",
DeliverMin: 852156963,
CheckID : "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
} as any
assert.throws(
() => verifyCheckCash(invalidDeliverMin),
ValidationError,
"CheckCash: cannot have both Amount and DeliverMin"
);
});
assert.throws(
() => verifyCheckCash(invalidDeliverMin),
ValidationError,
"CheckCash: invalid DeliverMin"
)
})
})
it(`throws w/ invalid DeliverMin`, function () {
const invalidDeliverMin = {
Account: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
TransactionType: "CheckCash",
DeliverMin: 852156963,
CheckID:
"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334",
} as any;
assert.throws(
() => verifyCheckCash(invalidDeliverMin),
ValidationError,
"CheckCash: invalid DeliverMin"
);
});
});

View File

@@ -1,123 +1,127 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyCheckCreate } from './../../src/models/transactions/checkCreate'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyCheckCreate } from "../../src/models/transactions/checkCreate";
/**
* CheckCreate Transaction Verification Testing
* CheckCreate Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('CheckCreate Transaction Verification', function () {
it (`verifies valid CheckCreate`, () => {
const validCheck = {
TransactionType : "CheckCreate",
Account : "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax : "100000000",
Expiration : 570113521,
InvoiceID : "6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
DestinationTag : 1,
Fee : "12"
} as any
assert.doesNotThrow(() => verifyCheckCreate(validCheck))
})
describe("CheckCreate Transaction Verification", function () {
it(`verifies valid CheckCreate`, function () {
const validCheck = {
TransactionType: "CheckCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax: "100000000",
Expiration: 570113521,
InvoiceID:
"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
DestinationTag: 1,
Fee: "12",
} as any;
assert.doesNotThrow(() => verifyCheckCreate(validCheck));
});
it (`throws w/ invalid Destination`, () => {
const invalidDestination = {
TransactionType : "CheckCreate",
Account : "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination : 7896214563214789632154,
SendMax : "100000000",
Expiration : 570113521,
InvoiceID : "6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
DestinationTag : 1,
Fee : "12"
} as any
it(`throws w/ invalid Destination`, function () {
const invalidDestination = {
TransactionType: "CheckCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination: 7896214563214789632154,
SendMax: "100000000",
Expiration: 570113521,
InvoiceID:
"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
DestinationTag: 1,
Fee: "12",
} as any;
assert.throws(
() => verifyCheckCreate(invalidDestination),
ValidationError,
"CheckCreate: invalid Destination"
)
})
assert.throws(
() => verifyCheckCreate(invalidDestination),
ValidationError,
"CheckCreate: invalid Destination"
);
});
it (`throws w/ invalid SendMax`, () => {
const invalidSendMax = {
TransactionType : "CheckCreate",
Account : "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax : 100000000,
Expiration : 570113521,
InvoiceID : "6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
DestinationTag : 1,
Fee : "12"
} as any
it(`throws w/ invalid SendMax`, function () {
const invalidSendMax = {
TransactionType: "CheckCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax: 100000000,
Expiration: 570113521,
InvoiceID:
"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
DestinationTag: 1,
Fee: "12",
} as any;
assert.throws(
() => verifyCheckCreate(invalidSendMax),
ValidationError,
"CheckCreate: invalid SendMax"
)
})
assert.throws(
() => verifyCheckCreate(invalidSendMax),
ValidationError,
"CheckCreate: invalid SendMax"
);
});
it (`throws w/ invalid DestinationTag`, () => {
const invalidDestinationTag = {
TransactionType : "CheckCreate",
Account : "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax : "100000000",
Expiration : 570113521,
InvoiceID : "6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
DestinationTag : "1",
Fee : "12"
} as any
it(`throws w/ invalid DestinationTag`, function () {
const invalidDestinationTag = {
TransactionType: "CheckCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax: "100000000",
Expiration: 570113521,
InvoiceID:
"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
DestinationTag: "1",
Fee: "12",
} as any;
assert.throws(
() => verifyCheckCreate(invalidDestinationTag),
ValidationError,
"CheckCreate: invalid DestinationTag"
)
})
assert.throws(
() => verifyCheckCreate(invalidDestinationTag),
ValidationError,
"CheckCreate: invalid DestinationTag"
);
});
it (`throws w/ invalid Expiration`, () => {
const invalidExpiration = {
TransactionType : "CheckCreate",
Account : "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax : "100000000",
Expiration : "570113521",
InvoiceID : "6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
DestinationTag : 1,
Fee : "12"
} as any
it(`throws w/ invalid Expiration`, function () {
const invalidExpiration = {
TransactionType: "CheckCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax: "100000000",
Expiration: "570113521",
InvoiceID:
"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
DestinationTag: 1,
Fee: "12",
} as any;
assert.throws(
() => verifyCheckCreate(invalidExpiration),
ValidationError,
"CheckCreate: invalid Expiration"
)
})
assert.throws(
() => verifyCheckCreate(invalidExpiration),
ValidationError,
"CheckCreate: invalid Expiration"
);
});
it (`throws w/ invalid InvoiceID`, () => {
const invalidInvoiceID = {
TransactionType : "CheckCreate",
Account : "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax : "100000000",
Expiration : 570113521,
InvoiceID : 7896545655285446963258531,
DestinationTag : 1,
Fee : "12"
} as any
it(`throws w/ invalid InvoiceID`, function () {
const invalidInvoiceID = {
TransactionType: "CheckCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Destination: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
SendMax: "100000000",
Expiration: 570113521,
InvoiceID: 7896545655285446963258531,
DestinationTag: 1,
Fee: "12",
} as any;
assert.throws(
() => verifyCheckCreate(invalidInvoiceID),
ValidationError,
"CheckCreate: invalid InvoiceID"
)
})
})
assert.throws(
() => verifyCheckCreate(invalidInvoiceID),
ValidationError,
"CheckCreate: invalid InvoiceID"
);
});
});

View File

@@ -1,83 +1,85 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyDepositPreauth } from './../../src/models/transactions/depositPreauth'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyDepositPreauth } from "../../src/models/transactions/depositPreauth";
/**
* DepositPreauth Transaction Verification Testing
* DepositPreauth Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('DepositPreauth Transaction Verification', () => {
let depositPreauth
describe("DepositPreauth Transaction Verification", function () {
let depositPreauth;
beforeEach(() => {
depositPreauth = {
TransactionType: 'DepositPreauth',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
} as any
})
beforeEach(function () {
depositPreauth = {
TransactionType: "DepositPreauth",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
} as any;
});
it ('verifies valid DepositPreauth when only Authorize is provided', () => {
depositPreauth.Authorize = 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW'
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth))
})
it("verifies valid DepositPreauth when only Authorize is provided", function () {
depositPreauth.Authorize = "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW";
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth));
});
it ('verifies valid DepositPreauth when only Unauthorize is provided', () => {
depositPreauth.Unauthorize = 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n'
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth))
})
it("verifies valid DepositPreauth when only Unauthorize is provided", function () {
depositPreauth.Unauthorize = "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n";
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth));
});
it ('throws when both Authorize and Unauthorize are provided', () => {
depositPreauth.Authorize = 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW'
depositPreauth.Unauthorize = 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n'
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: can't provide both Authorize and Unauthorize fields"
)
})
it("throws when both Authorize and Unauthorize are provided", function () {
depositPreauth.Authorize = "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW";
depositPreauth.Unauthorize = "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n";
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: can't provide both Authorize and Unauthorize fields"
);
});
it ('throws when neither Authorize nor Unauthorize are provided', () => {
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
'DepositPreauth: must provide either Authorize or Unauthorize field'
)
})
it("throws when neither Authorize nor Unauthorize are provided", function () {
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: must provide either Authorize or Unauthorize field"
);
});
it ('throws when Authorize is not a string', () => {
depositPreauth.Authorize = 1234
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
'DepositPreauth: Authorize must be a string'
)
})
it("throws when Authorize is not a string", function () {
depositPreauth.Authorize = 1234;
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: Authorize must be a string"
);
});
it ('throws when an Account attempts to preauthorize its own address', () => {
depositPreauth.Authorize = depositPreauth.Account
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: Account can't preauthorize its own address"
)
})
it("throws when an Account attempts to preauthorize its own address", function () {
depositPreauth.Authorize = depositPreauth.Account;
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: Account can't preauthorize its own address"
);
});
it ('throws when Unauthorize is not a string', () => {
depositPreauth.Unauthorize = 1234
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
'DepositPreauth: Unauthorize must be a string'
)
})
it("throws when Unauthorize is not a string", function () {
depositPreauth.Unauthorize = 1234;
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: Unauthorize must be a string"
);
});
it ('throws when an Account attempts to unauthorize its own address', () => {
depositPreauth.Unauthorize = depositPreauth.Account
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: Account can't unauthorize its own address"
)
})
})
it("throws when an Account attempts to unauthorize its own address", function () {
depositPreauth.Unauthorize = depositPreauth.Account;
assert.throws(
() => verifyDepositPreauth(depositPreauth),
ValidationError,
"DepositPreauth: Account can't unauthorize its own address"
);
});
});

View File

@@ -1,65 +1,66 @@
import { verifyEscrowCancel } from './../../src/models/transactions/escrowCancel'
import { assert } from 'chai'
import { ValidationError } from '../../src/common/errors'
import { assert } from "chai";
import { ValidationError } from "../../src/common/errors";
import { verifyEscrowCancel } from "../../src/models/transactions/escrowCancel";
/**
* Transaction Verification Testing
* Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('Transaction Verification', function () {
let cancel
describe("Transaction Verification", function () {
let cancel;
beforeEach(() => {
cancel = {
TransactionType: "EscrowCancel",
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Owner: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
OfferSequence: 7,
}
})
beforeEach(function () {
cancel = {
TransactionType: "EscrowCancel",
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Owner: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
OfferSequence: 7,
};
});
it (`Valid EscrowCancel`, () => {
assert.doesNotThrow(() => verifyEscrowCancel(cancel))
})
it(`Valid EscrowCancel`, function () {
assert.doesNotThrow(() => verifyEscrowCancel(cancel));
});
it (`Invalid EscrowCancel missing owner`, () => {
delete cancel.Owner
it(`Invalid EscrowCancel missing owner`, function () {
delete cancel.Owner;
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
'EscrowCancel: missing Owner'
)
})
it (`Invalid EscrowCancel missing offerSequence`, () => {
delete cancel.OfferSequence
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
"EscrowCancel: missing Owner"
);
});
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
'EscrowCancel: missing OfferSequence'
)
})
it(`Invalid EscrowCancel missing offerSequence`, function () {
delete cancel.OfferSequence;
it (`Invalid OfferSequence`, () => {
cancel.Owner = 10
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
"EscrowCancel: missing OfferSequence"
);
});
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
'EscrowCancel: Owner must be a string'
)
})
it(`Invalid OfferSequence`, function () {
cancel.Owner = 10;
it (`Invalid owner`, () => {
cancel.OfferSequence = "10"
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
"EscrowCancel: Owner must be a string"
);
});
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
'EscrowCancel: OfferSequence must be a number'
)
})
})
it(`Invalid owner`, function () {
cancel.OfferSequence = "10";
assert.throws(
() => verifyEscrowCancel(cancel),
ValidationError,
"EscrowCancel: OfferSequence must be a number"
);
});
});

View File

@@ -1,132 +1,135 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyEscrowCreate } from './../../src/models/transactions/escrowCreate'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyEscrowCreate } from "../../src/models/transactions/escrowCreate";
/**
* EscrowCreate Transaction Verification Testing
* EscrowCreate Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('EscrowCreate Transaction Verification', function () {
let escrow
describe("EscrowCreate Transaction Verification", function () {
let escrow;
beforeEach(() => {
escrow = {
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
TransactionType: "EscrowCreate",
Amount: "10000",
Destination: "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
CancelAfter: 533257958,
FinishAfter: 533171558,
Condition: "A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100",
DestinationTag: 23480,
SourceTag: 11747
}
})
it (`verifies valid EscrowCreate`, () => {
assert.doesNotThrow(() => verifyEscrowCreate(escrow))
})
beforeEach(function () {
escrow = {
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
TransactionType: "EscrowCreate",
Amount: "10000",
Destination: "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
CancelAfter: 533257958,
FinishAfter: 533171558,
Condition:
"A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100",
DestinationTag: 23480,
SourceTag: 11747,
};
});
it (`Missing amount`, () => {
delete escrow.Amount
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: missing field Amount"
)
})
it(`verifies valid EscrowCreate`, function () {
assert.doesNotThrow(() => verifyEscrowCreate(escrow));
});
it (`Missing destination`, () => {
delete escrow.Destination
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: missing field Destination"
)
})
it(`Missing amount`, function () {
delete escrow.Amount;
it (`throws w/ invalid Destination`, () => {
escrow.Destination = 10
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: missing field Amount"
);
});
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Destination must be a string"
)
})
it(`Missing destination`, function () {
delete escrow.Destination;
it (`throws w/ invalid Amount`, () => {
escrow.Amount = 1000
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: missing field Destination"
);
});
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Amount must be a string"
)
})
it(`throws w/ invalid Destination`, function () {
escrow.Destination = 10;
it (`invalid CancelAfter`, () => {
escrow.CancelAfter = "100"
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: CancelAfter must be a number"
)
})
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Destination must be a string"
);
});
it (`invalid FinishAfter`, () => {
escrow.FinishAfter = "1000"
it(`throws w/ invalid Amount`, function () {
escrow.Amount = 1000;
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: FinishAfter must be a number"
)
})
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Amount must be a string"
);
});
it (`invalid Condition`, () => {
escrow.Condition = 0x141243
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Condition must be a string"
)
})
it(`invalid CancelAfter`, function () {
escrow.CancelAfter = "100";
it (`invalid DestinationTag`, () => {
escrow.DestinationTag = "100"
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: DestinationTag must be a number"
)
})
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: CancelAfter must be a number"
);
});
it (`Missing both CancelAfter and FinishAfter`, () => {
delete escrow.CancelAfter
delete escrow.FinishAfter
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Either CancelAfter or FinishAfter must be specified"
)
})
it(`invalid FinishAfter`, function () {
escrow.FinishAfter = "1000";
it (`Missing both Condition and FinishAfter`, () => {
delete escrow.Condition
delete escrow.FinishAfter
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Either Condition or FinishAfter must be specified"
)
})
})
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: FinishAfter must be a number"
);
});
it(`invalid Condition`, function () {
escrow.Condition = 0x141243;
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Condition must be a string"
);
});
it(`invalid DestinationTag`, function () {
escrow.DestinationTag = "100";
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: DestinationTag must be a number"
);
});
it(`Missing both CancelAfter and FinishAfter`, function () {
delete escrow.CancelAfter;
delete escrow.FinishAfter;
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Either CancelAfter or FinishAfter must be specified"
);
});
it(`Missing both Condition and FinishAfter`, function () {
delete escrow.Condition;
delete escrow.FinishAfter;
assert.throws(
() => verifyEscrowCreate(escrow),
ValidationError,
"EscrowCreate: Either Condition or FinishAfter must be specified"
);
});
});

View File

@@ -1,75 +1,76 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyEscrowFinish } from './../../src/models/transactions/escrowFinish'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyEscrowFinish } from "../../src/models/transactions/escrowFinish";
/**
* EscrowFinish Transaction Verification Testing
* EscrowFinish Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('EscrowFinish Transaction Verification', function () {
let escrow
describe("EscrowFinish Transaction Verification", function () {
let escrow;
beforeEach(() => {
escrow = {
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
TransactionType: "EscrowFinish",
Owner: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
OfferSequence: 7,
Condition: "A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100",
Fulfillment: "A0028000"
}
})
it (`verifies valid EscrowFinish`, () => {
assert.doesNotThrow(() => verifyEscrowFinish(escrow))
})
beforeEach(function () {
escrow = {
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
TransactionType: "EscrowFinish",
Owner: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
OfferSequence: 7,
Condition:
"A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100",
Fulfillment: "A0028000",
};
});
it(`verifies valid EscrowFinish`, function () {
assert.doesNotThrow(() => verifyEscrowFinish(escrow));
});
it (`verifies valid EscrowFinish w/o optional`, () => {
delete escrow.Condition
delete escrow.Fulfillment
assert.doesNotThrow(() => verifyEscrowFinish(escrow))
})
it(`verifies valid EscrowFinish w/o optional`, function () {
delete escrow.Condition;
delete escrow.Fulfillment;
assert.doesNotThrow(() => verifyEscrowFinish(escrow));
});
it (`throws w/ invalid Owner`, () => {
escrow.Owner = 0x15415253
it(`throws w/ invalid Owner`, function () {
escrow.Owner = 0x15415253;
assert.throws(
() => verifyEscrowFinish(escrow),
ValidationError,
"EscrowFinish: Owner must be a string"
)
})
assert.throws(
() => verifyEscrowFinish(escrow),
ValidationError,
"EscrowFinish: Owner must be a string"
);
});
it (`throws w/ invalid OfferSequence`, () => {
escrow.OfferSequence = "10"
it(`throws w/ invalid OfferSequence`, function () {
escrow.OfferSequence = "10";
assert.throws(
() => verifyEscrowFinish(escrow),
ValidationError,
"EscrowFinish: OfferSequence must be a number"
)
})
assert.throws(
() => verifyEscrowFinish(escrow),
ValidationError,
"EscrowFinish: OfferSequence must be a number"
);
});
it (`throws w/ invalid Condition`, () => {
escrow.Condition = 10
it(`throws w/ invalid Condition`, function () {
escrow.Condition = 10;
assert.throws(
() => verifyEscrowFinish(escrow),
ValidationError,
"EscrowFinish: Condition must be a string"
)
})
assert.throws(
() => verifyEscrowFinish(escrow),
ValidationError,
"EscrowFinish: Condition must be a string"
);
});
it (`throws w/ invalid Fulfillment`, () => {
escrow.Fulfillment = 0x142341
it(`throws w/ invalid Fulfillment`, function () {
escrow.Fulfillment = 0x142341;
assert.throws(
() => verifyEscrowFinish(escrow),
ValidationError,
"EscrowFinish: Fulfillment must be a string"
)
})
})
assert.throws(
() => verifyEscrowFinish(escrow),
ValidationError,
"EscrowFinish: Fulfillment must be a string"
);
});
});

View File

@@ -1,53 +1,57 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyOfferCancel } from './../../src/models/transactions/offerCancel'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyOfferCancel } from "../../src/models/transactions/offerCancel";
/**
* OfferCancel Transaction Verification Testing
* OfferCancel Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('OfferCancel Transaction Verification', function () {
let offer
beforeEach(() => {
offer = {
Account: "rnKiczmiQkZFiDES8THYyLA2pQohC5C6EF",
Fee: "10",
LastLedgerSequence: 65477334,
OfferSequence: 60797528,
Sequence: 60797535,
SigningPubKey: "0361BFD43D1EEA54B77CC152887312949EBF052997FBFFCDAF6F2653164B55B21...",
TransactionType: "OfferCancel",
TxnSignature: "30450221008C43BDCFC68B4793857CA47DF454C07E5B45D3F80E8E6785CAB9292...",
date: "2021-08-06T21:04:11Z"
} as any
})
describe("OfferCancel Transaction Verification", function () {
let offer;
it (`verifies valid OfferCancel`, () => {
assert.doesNotThrow(() => verifyOfferCancel(offer))
})
beforeEach(function () {
offer = {
Account: "rnKiczmiQkZFiDES8THYyLA2pQohC5C6EF",
Fee: "10",
LastLedgerSequence: 65477334,
OfferSequence: 60797528,
Sequence: 60797535,
SigningPubKey:
"0361BFD43D1EEA54B77CC152887312949EBF052997FBFFCDAF6F2653164B55B21...",
TransactionType: "OfferCancel",
TxnSignature:
"30450221008C43BDCFC68B4793857CA47DF454C07E5B45D3F80E8E6785CAB9292...",
date: "2021-08-06T21:04:11Z",
} as any;
});
it (`verifies valid OfferCancel with flags`, () => {
offer.Flags = 2147483648
assert.doesNotThrow(() => verifyOfferCancel(offer))
})
it(`verifies valid OfferCancel`, function () {
assert.doesNotThrow(() => verifyOfferCancel(offer));
});
it (`throws w/ OfferSequence must be a number`, () => {
offer.OfferSequence = '99'
assert.throws(
() => verifyOfferCancel(offer),
ValidationError,
"OfferCancel: OfferSequence must be a number"
)
})
it(`verifies valid OfferCancel with flags`, function () {
offer.Flags = 2147483648;
assert.doesNotThrow(() => verifyOfferCancel(offer));
});
it (`throws w/ missing OfferSequence`, () => {
delete offer.OfferSequence
assert.throws(
() => verifyOfferCancel(offer),
ValidationError,
"OfferCancel: missing field OfferSequence"
)
})
})
it(`throws w/ OfferSequence must be a number`, function () {
offer.OfferSequence = "99";
assert.throws(
() => verifyOfferCancel(offer),
ValidationError,
"OfferCancel: OfferSequence must be a number"
);
});
it(`throws w/ missing OfferSequence`, function () {
delete offer.OfferSequence;
assert.throws(
() => verifyOfferCancel(offer),
ValidationError,
"OfferCancel: missing field OfferSequence"
);
});
});

View File

@@ -1,177 +1,191 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyOfferCreate } from './../../src/models/transactions/offerCreate'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyOfferCreate } from "../../src/models/transactions/offerCreate";
/**
* OfferCreate Transaction Verification Testing
* OfferCreate Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('OfferCreate Transaction Verification', function () {
it (`verifies valid OfferCreate`, () => {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey: "03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
Expiration: 10,
OfferSequence: 12,
TakerGets: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009"
},
TakerPays: "12928290425",
TransactionType: "OfferCreate",
TxnSignature: "3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any
assert.doesNotThrow(() => verifyOfferCreate(offer))
describe("OfferCreate Transaction Verification", function () {
it(`verifies valid OfferCreate`, function () {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
Expiration: 10,
OfferSequence: 12,
TakerGets: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
},
TakerPays: "12928290425",
TransactionType: "OfferCreate",
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
const offer2 = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey: "03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
TakerGets: "12928290425",
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009"
},
TransactionType: "OfferCreate",
TxnSignature: "3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any
assert.doesNotThrow(() => verifyOfferCreate(offer));
assert.doesNotThrow(() => verifyOfferCreate(offer2))
const offer2 = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
TakerGets: "12928290425",
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
},
TransactionType: "OfferCreate",
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
assert.doesNotThrow(() => verifyOfferCreate(offer2));
const offer3 = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey: "03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
TakerGets: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009"
},
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009"
},
TransactionType: "OfferCreate",
TxnSignature: "3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any
const offer3 = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
TakerGets: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
},
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
},
TransactionType: "OfferCreate",
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
assert.doesNotThrow(() => verifyOfferCreate(offer3))
})
assert.doesNotThrow(() => verifyOfferCreate(offer3));
});
it (`throws w/ invalid Expiration`, () => {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey: "03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
Expiration: "11",
TakerGets: "12928290425",
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009"
},
TransactionType: "OfferCreate",
TxnSignature: "3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any
it(`throws w/ invalid Expiration`, function () {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
Expiration: "11",
TakerGets: "12928290425",
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
},
TransactionType: "OfferCreate",
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
assert.throws(
() => verifyOfferCreate(offer),
ValidationError,
"OfferCreate: invalid Expiration"
)
})
assert.throws(
() => verifyOfferCreate(offer),
ValidationError,
"OfferCreate: invalid Expiration"
);
});
it (`throws w/ invalid OfferSequence`, () => {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey: "03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
OfferSequence: "11",
TakerGets: "12928290425",
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009"
},
TransactionType: "OfferCreate",
TxnSignature: "3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any
it(`throws w/ invalid OfferSequence`, function () {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
OfferSequence: "11",
TakerGets: "12928290425",
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
},
TransactionType: "OfferCreate",
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
assert.throws(
() => verifyOfferCreate(offer),
ValidationError,
"OfferCreate: invalid OfferSequence"
)
})
assert.throws(
() => verifyOfferCreate(offer),
ValidationError,
"OfferCreate: invalid OfferSequence"
);
});
it (`throws w/ invalid TakerPays`, () => {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey: "03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
OfferSequence: "11",
TakerGets: "12928290425",
TakerPays: 10,
TransactionType: "OfferCreate",
TxnSignature: "3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any
it(`throws w/ invalid TakerPays`, function () {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
OfferSequence: "11",
TakerGets: "12928290425",
TakerPays: 10,
TransactionType: "OfferCreate",
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
assert.throws(
() => verifyOfferCreate(offer),
ValidationError,
"OfferCreate: invalid TakerPays"
)
})
assert.throws(
() => verifyOfferCreate(offer),
ValidationError,
"OfferCreate: invalid TakerPays"
);
});
it (`throws w/ invalid TakerGets`, () => {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey: "03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
OfferSequence: "11",
TakerGets: 11,
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009"
},
TransactionType: "OfferCreate",
TxnSignature: "3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any
it(`throws w/ invalid TakerGets`, function () {
const offer = {
Account: "r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W",
Fee: "10",
Flags: 0,
LastLedgerSequence: 65453019,
Sequence: 40949322,
SigningPubKey:
"03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22",
OfferSequence: "11",
TakerGets: 11,
TakerPays: {
currency: "DSH",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "43.11584856965009",
},
TransactionType: "OfferCreate",
TxnSignature:
"3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91",
} as any;
assert.throws(
() => verifyOfferCreate(offer),
ValidationError,
"OfferCreate: invalid TakerGets"
)
})
})
assert.throws(
() => verifyOfferCreate(offer),
ValidationError,
"OfferCreate: invalid TakerGets"
);
});
});

View File

@@ -1,98 +1,102 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyPaymentChannelClaim } from './../../src/models/transactions/paymentChannelClaim'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyPaymentChannelClaim } from "../../src/models/transactions/paymentChannelClaim";
/**
* PaymentChannelClaim Transaction Verification Testing
* PaymentChannelClaim Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('PaymentChannelClaim Transaction Verification', function () {
let channel
describe("PaymentChannelClaim Transaction Verification", function () {
let channel;
beforeEach(() => {
channel = {
"Account": "r...",
"TransactionType": "PaymentChannelClaim",
"Channel": "C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198",
"Balance": "1000000",
"Amount": "1000000",
"Signature": "30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B",
"PublicKey": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A"
}
})
beforeEach(function () {
channel = {
Account: "r...",
TransactionType: "PaymentChannelClaim",
Channel:
"C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198",
Balance: "1000000",
Amount: "1000000",
Signature:
"30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B",
PublicKey:
"32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A",
};
});
it (`verifies valid PaymentChannelClaim`, () => {
assert.doesNotThrow(() => verifyPaymentChannelClaim(channel))
})
it(`verifies valid PaymentChannelClaim`, function () {
assert.doesNotThrow(() => verifyPaymentChannelClaim(channel));
});
it (`verifies valid PaymentChannelClaim w/o optional`, () => {
delete channel.Balance
delete channel.Amount
delete channel.Signature
delete channel.PublicKey
assert.doesNotThrow(() => verifyPaymentChannelClaim(channel))
})
it(`verifies valid PaymentChannelClaim w/o optional`, function () {
delete channel.Balance;
delete channel.Amount;
delete channel.Signature;
delete channel.PublicKey;
it (`throws w/ missing Channel`, () => {
delete channel.Channel
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: missing Channel"
)
})
assert.doesNotThrow(() => verifyPaymentChannelClaim(channel));
});
it (`throws w/ invalid Channel`, () => {
channel.Channel = 100
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: Channel must be a string"
)
})
it(`throws w/ missing Channel`, function () {
delete channel.Channel;
it (`throws w/ invalid Balance`, () => {
channel.Balance = 100
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: Balance must be a string"
)
})
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: missing Channel"
);
});
it (`throws w/ invalid Amount`, () => {
channel.Amount = 1000
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: Amount must be a string"
)
})
it(`throws w/ invalid Channel`, function () {
channel.Channel = 100;
it (`throws w/ invalid Signature`, () => {
channel.Signature = 1000
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: Signature must be a string"
)
})
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: Channel must be a string"
);
});
it (`throws w/ invalid PublicKey`, () => {
channel.PublicKey = ["100000"]
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: PublicKey must be a string"
)
})
})
it(`throws w/ invalid Balance`, function () {
channel.Balance = 100;
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: Balance must be a string"
);
});
it(`throws w/ invalid Amount`, function () {
channel.Amount = 1000;
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: Amount must be a string"
);
});
it(`throws w/ invalid Signature`, function () {
channel.Signature = 1000;
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: Signature must be a string"
);
});
it(`throws w/ invalid PublicKey`, function () {
channel.PublicKey = ["100000"];
assert.throws(
() => verifyPaymentChannelClaim(channel),
ValidationError,
"PaymentChannelClaim: PublicKey must be a string"
);
});
});

View File

@@ -1,140 +1,141 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyPaymentChannelCreate } from './../../src/models/transactions/paymentChannelCreate'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyPaymentChannelCreate } from "../../src/models/transactions/paymentChannelCreate";
/**
* PaymentChannelCreate Transaction Verification Testing
* PaymentChannelCreate Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('PaymentChannelCreate Transaction Verification', function () {
let channel
describe("PaymentChannelCreate Transaction Verification", function () {
let channel;
beforeEach(() => {
channel = {
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"TransactionType": "PaymentChannelCreate",
"Amount": "10000",
"Destination": "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
"SettleDelay": 86400,
"PublicKey": "32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A",
"CancelAfter": 533171558,
"DestinationTag": 23480,
"SourceTag": 11747
}
})
it (`verifies valid PaymentChannelCreate`, () => {
assert.doesNotThrow(() => verifyPaymentChannelCreate(channel))
})
beforeEach(function () {
channel = {
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
TransactionType: "PaymentChannelCreate",
Amount: "10000",
Destination: "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
SettleDelay: 86400,
PublicKey:
"32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A",
CancelAfter: 533171558,
DestinationTag: 23480,
SourceTag: 11747,
};
});
it (`verifies valid PaymentChannelCreate w/o optional`, () => {
delete channel.CancelAfter
delete channel.DestinationTag
delete channel.SourceTag
it(`verifies valid PaymentChannelCreate`, function () {
assert.doesNotThrow(() => verifyPaymentChannelCreate(channel));
});
assert.doesNotThrow(() => verifyPaymentChannelCreate(channel))
})
it(`verifies valid PaymentChannelCreate w/o optional`, function () {
delete channel.CancelAfter;
delete channel.DestinationTag;
delete channel.SourceTag;
it (`missing Amount`, () => {
delete channel.Amount
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: missing Amount"
)
})
assert.doesNotThrow(() => verifyPaymentChannelCreate(channel));
});
it(`missing Amount`, function () {
delete channel.Amount;
it (`missing Destination`, () => {
delete channel.Destination
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: missing Destination"
)
})
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: missing Amount"
);
});
it (`missing SettleDelay`, () => {
delete channel.SettleDelay
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: missing SettleDelay"
)
})
it(`missing Destination`, function () {
delete channel.Destination;
it (`missing PublicKey`, () => {
delete channel.PublicKey
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: missing PublicKey"
)
})
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: missing Destination"
);
});
it (`invalid Amount`, () => {
channel.Amount = 1000
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: Amount must be a string"
)
})
it(`missing SettleDelay`, function () {
delete channel.SettleDelay;
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: missing SettleDelay"
);
});
it (`invalid Destination`, () => {
channel.Destination = 10;
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: Destination must be a string"
)
})
it(`missing PublicKey`, function () {
delete channel.PublicKey;
it (`invalid SettleDelay`, () => {
channel.SettleDelay = "10"
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: SettleDelay must be a number"
)
})
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: missing PublicKey"
);
});
it (`invalid PublicKey`, () => {
channel.PublicKey = 10
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: PublicKey must be a string"
)
})
it(`invalid Amount`, function () {
channel.Amount = 1000;
it (`invalid DestinationTag`, () => {
channel.DestinationTag = "10"
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: Amount must be a string"
);
});
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: DestinationTag must be a number"
)
})
it(`invalid Destination`, function () {
channel.Destination = 10;
it (`invalid CancelAfter`, () => {
channel.CancelAfter = "100"
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: CancelAfter must be a number"
)
})
})
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: Destination must be a string"
);
});
it(`invalid SettleDelay`, function () {
channel.SettleDelay = "10";
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: SettleDelay must be a number"
);
});
it(`invalid PublicKey`, function () {
channel.PublicKey = 10;
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: PublicKey must be a string"
);
});
it(`invalid DestinationTag`, function () {
channel.DestinationTag = "10";
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: DestinationTag must be a number"
);
});
it(`invalid CancelAfter`, function () {
channel.CancelAfter = "100";
assert.throws(
() => verifyPaymentChannelCreate(channel),
ValidationError,
"PaymentChannelCreate: CancelAfter must be a number"
);
});
});

View File

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

View File

@@ -1,132 +1,140 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { PaymentTransactionFlagsEnum, verifyPaymentTransaction } from './../../src/models/transactions/paymentTransaction'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import {
PaymentTransactionFlagsEnum,
verifyPaymentTransaction,
} from "../../src/models/transactions/paymentTransaction";
/**
* PaymentTransaction Verification Testing
* PaymentTransaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('Payment Transaction Verification', () => {
let paymentTransaction
describe("Payment Transaction Verification", function () {
let paymentTransaction;
beforeEach(() => {
paymentTransaction = {
TransactionType: 'Payment',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
Amount: '1234',
Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
DestinationTag: 1,
InvoiceID: '6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
Paths: [[{ account: 'aw0efji', currency: 'XRP', issuer: 'apsoeijf90wp34fh'}]],
SendMax: '100000000',
} as any
})
beforeEach(function () {
paymentTransaction = {
TransactionType: "Payment",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
Amount: "1234",
Destination: "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
DestinationTag: 1,
InvoiceID:
"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
Paths: [
[{ account: "aw0efji", currency: "XRP", issuer: "apsoeijf90wp34fh" }],
],
SendMax: "100000000",
} as any;
});
it (`verifies valid PaymentTransaction`, () => {
assert.doesNotThrow(() => verifyPaymentTransaction(paymentTransaction))
})
it(`verifies valid PaymentTransaction`, function () {
assert.doesNotThrow(() => verifyPaymentTransaction(paymentTransaction));
});
it (`throws when Amount is missing`, () => {
delete paymentTransaction.Amount
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
'PaymentTransaction: missing field Amount'
)
})
it(`throws when Amount is missing`, function () {
delete paymentTransaction.Amount;
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
"PaymentTransaction: missing field Amount"
);
});
it (`throws when Amount is invalid`, () => {
paymentTransaction.Amount = 1234
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
'PaymentTransaction: invalid Amount'
)
})
it(`throws when Amount is invalid`, function () {
paymentTransaction.Amount = 1234;
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
"PaymentTransaction: invalid Amount"
);
});
it (`throws when Destination is missing`, () => {
delete paymentTransaction.Destination
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
'PaymentTransaction: missing field Destination'
)
})
it(`throws when Destination is missing`, function () {
delete paymentTransaction.Destination;
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
"PaymentTransaction: missing field Destination"
);
});
it (`throws when Destination is invalid`, () => {
paymentTransaction.Destination = 7896214
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
'PaymentTransaction: invalid Destination'
)
})
it(`throws when Destination is invalid`, function () {
paymentTransaction.Destination = 7896214;
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
"PaymentTransaction: invalid Destination"
);
});
it (`throws when DestinationTag is not a number`, () => {
paymentTransaction.DestinationTag = '1'
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
'PaymentTransaction: DestinationTag must be a number'
)
})
it(`throws when DestinationTag is not a number`, function () {
paymentTransaction.DestinationTag = "1";
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
"PaymentTransaction: DestinationTag must be a number"
);
});
it (`throws when InvoiceID is not a string`, () => {
paymentTransaction.InvoiceID = 19832
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
'PaymentTransaction: InvoiceID must be a string'
)
})
it(`throws when InvoiceID is not a string`, function () {
paymentTransaction.InvoiceID = 19832;
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
"PaymentTransaction: InvoiceID must be a string"
);
});
it (`throws when Paths is invalid`, () => {
paymentTransaction.Paths = [[{ account: 123 }]]
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
'PaymentTransaction: invalid Paths'
)
})
it(`throws when Paths is invalid`, function () {
paymentTransaction.Paths = [[{ account: 123 }]];
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
"PaymentTransaction: invalid Paths"
);
});
it (`throws when SendMax is invalid`, () => {
paymentTransaction.SendMax = 100000000
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
'PaymentTransaction: invalid SendMax'
)
})
it(`throws when SendMax is invalid`, function () {
paymentTransaction.SendMax = 100000000;
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
"PaymentTransaction: invalid SendMax"
);
});
it (`verifies valid DeliverMin with tfPartialPayment flag set as a number`, () => {
paymentTransaction.DeliverMin = '10000'
paymentTransaction.Flags = PaymentTransactionFlagsEnum.tfPartialPayment,
assert.doesNotThrow(() => verifyPaymentTransaction(paymentTransaction))
})
it(`verifies valid DeliverMin with tfPartialPayment flag set as a number`, function () {
paymentTransaction.DeliverMin = "10000";
(paymentTransaction.Flags = PaymentTransactionFlagsEnum.tfPartialPayment),
assert.doesNotThrow(() => verifyPaymentTransaction(paymentTransaction));
});
it (`verifies valid DeliverMin with tfPartialPayment flag set as a boolean`, () => {
paymentTransaction.DeliverMin = '10000'
paymentTransaction.Flags = { tfPartialPayment: true }
assert.doesNotThrow(() => verifyPaymentTransaction(paymentTransaction))
})
it(`verifies valid DeliverMin with tfPartialPayment flag set as a boolean`, function () {
paymentTransaction.DeliverMin = "10000";
paymentTransaction.Flags = { tfPartialPayment: true };
assert.doesNotThrow(() => verifyPaymentTransaction(paymentTransaction));
});
it (`throws when DeliverMin is invalid`, () => {
paymentTransaction.DeliverMin = 10000
paymentTransaction.Flags = { tfPartialPayment: true }
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
'PaymentTransaction: invalid DeliverMin'
)
})
it(`throws when DeliverMin is invalid`, function () {
paymentTransaction.DeliverMin = 10000;
paymentTransaction.Flags = { tfPartialPayment: true };
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
"PaymentTransaction: invalid DeliverMin"
);
});
it (`throws when tfPartialPayment flag is missing with valid DeliverMin`, () => {
paymentTransaction.DeliverMin = '10000'
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
'PaymentTransaction: tfPartialPayment flag required with DeliverMin'
)
})
})
it(`throws when tfPartialPayment flag is missing with valid DeliverMin`, function () {
paymentTransaction.DeliverMin = "10000";
assert.throws(
() => verifyPaymentTransaction(paymentTransaction),
ValidationError,
"PaymentTransaction: tfPartialPayment flag required with DeliverMin"
);
});
});

View File

@@ -1,42 +1,43 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifySetRegularKey } from './../../src/models/transactions/setRegularKey'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifySetRegularKey } from "../../src/models/transactions/setRegularKey";
/**
* SetRegularKey Transaction Verification Testing
* SetRegularKey Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('SetRegularKey Transaction Verification', function () {
let account
describe("SetRegularKey Transaction Verification", function () {
let account;
beforeEach(() => {
account = {
TransactionType : "SetRegularKey",
Account : "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Fee : "12",
Flags : 0,
RegularKey : "rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD"
} as any
})
beforeEach(function () {
account = {
TransactionType: "SetRegularKey",
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Fee: "12",
Flags: 0,
RegularKey: "rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD",
} as any;
});
it (`verifies valid SetRegularKey`, () => {
assert.doesNotThrow(() => verifySetRegularKey(account))
})
it(`verifies valid SetRegularKey`, function () {
assert.doesNotThrow(() => verifySetRegularKey(account));
});
it (`verifies w/o SetRegularKey`, () => {
account.RegularKey = undefined
assert.doesNotThrow(() => verifySetRegularKey(account))
})
it(`verifies w/o SetRegularKey`, function () {
account.RegularKey = undefined;
assert.doesNotThrow(() => verifySetRegularKey(account));
});
it (`throws w/ invalid RegularKey`, () => {
account.RegularKey = 12369846963
it(`throws w/ invalid RegularKey`, function () {
account.RegularKey = 12369846963;
assert.throws(
() => verifySetRegularKey(account),
ValidationError,
"SetRegularKey: RegularKey must be a string"
)
})
})
assert.throws(
() => verifySetRegularKey(account),
ValidationError,
"SetRegularKey: RegularKey must be a string"
);
});
});

View File

@@ -1,77 +1,78 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifySignerListSet } from './../../src/models/transactions/signerListSet'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifySignerListSet } from "../../src/models/transactions/signerListSet";
/**
* SignerListSet Transaction Verification Testing
* SignerListSet Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('SignerListSet Transaction Verification', function () {
let SignerListSetTx
describe("SignerListSet Transaction Verification", function () {
let SignerListSetTx;
beforeEach(() => {
SignerListSetTx = {
Flags: 0,
TransactionType: "SignerListSet",
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Fee: "12",
SignerQuorum: 3,
SignerEntries: [
{
SignerEntry: {
Account: "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
SignerWeight: 2
}
},
{
SignerEntry: {
Account: "rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v",
SignerWeight: 1
}
},
{
SignerEntry: {
Account: "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n",
SignerWeight: 1
}
}
]
} as any
})
it (`verifies valid SignerListSet`, () => {
assert.doesNotThrow(() => verifySignerListSet(SignerListSetTx))
})
beforeEach(function () {
SignerListSetTx = {
Flags: 0,
TransactionType: "SignerListSet",
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
Fee: "12",
SignerQuorum: 3,
SignerEntries: [
{
SignerEntry: {
Account: "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW",
SignerWeight: 2,
},
},
{
SignerEntry: {
Account: "rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v",
SignerWeight: 1,
},
},
{
SignerEntry: {
Account: "raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n",
SignerWeight: 1,
},
},
],
} as any;
});
it(`verifies valid SignerListSet`, function () {
assert.doesNotThrow(() => verifySignerListSet(SignerListSetTx));
});
it (`throws w/ missing SignerQuorum`, () => {
SignerListSetTx.SignerQuorum = undefined
it(`throws w/ missing SignerQuorum`, function () {
SignerListSetTx.SignerQuorum = undefined;
assert.throws(
() => verifySignerListSet(SignerListSetTx),
ValidationError,
"SignerListSet: missing field SignerQuorum"
)
})
assert.throws(
() => verifySignerListSet(SignerListSetTx),
ValidationError,
"SignerListSet: missing field SignerQuorum"
);
});
it (`throws w/ empty SignerEntries`, () => {
SignerListSetTx.SignerEntries = []
it(`throws w/ empty SignerEntries`, function () {
SignerListSetTx.SignerEntries = [];
assert.throws(
() => verifySignerListSet(SignerListSetTx),
ValidationError,
"SignerListSet: need atleast 1 member in SignerEntries"
)
})
assert.throws(
() => verifySignerListSet(SignerListSetTx),
ValidationError,
"SignerListSet: need atleast 1 member in SignerEntries"
);
});
it (`throws w/ invalid SignerEntries`, () => {
SignerListSetTx.SignerEntries = "khgfgyhujk"
assert.throws(
() => verifySignerListSet(SignerListSetTx),
ValidationError,
"SignerListSet: invalid SignerEntries"
)
})
})
it(`throws w/ invalid SignerEntries`, function () {
SignerListSetTx.SignerEntries = "khgfgyhujk";
assert.throws(
() => verifySignerListSet(SignerListSetTx),
ValidationError,
"SignerListSet: invalid SignerEntries"
);
});
});

View File

@@ -1,69 +1,71 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyTicketCreate } from './../../src/models/transactions/ticketCreate'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyTicketCreate } from "../../src/models/transactions/ticketCreate";
/**
* TicketCreate Transaction Verification Testing
* TicketCreate Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('TicketCreate Transaction Verification', () => {
let ticketCreate
describe("TicketCreate Transaction Verification", function () {
let ticketCreate;
beforeEach(() => {
ticketCreate = {
TransactionType: 'TicketCreate',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
TicketCount: 150,
} as any
})
beforeEach(function () {
ticketCreate = {
TransactionType: "TicketCreate",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
TicketCount: 150,
} as any;
});
it ('verifies valid TicketCreate', () => {
assert.doesNotThrow(() => verifyTicketCreate(ticketCreate))
})
it("verifies valid TicketCreate", function () {
assert.doesNotThrow(() => verifyTicketCreate(ticketCreate));
});
it ('throws when TicketCount is missing', () => {
delete ticketCreate.TicketCount
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
'TicketCreate: missing field TicketCount'
)
})
it("throws when TicketCount is missing", function () {
delete ticketCreate.TicketCount;
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
"TicketCreate: missing field TicketCount"
);
});
it ('throws when TicketCount is not a number', () => {
ticketCreate.TicketCount = '150'
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
'TicketCreate: TicketCount must be a number'
)
})
it("throws when TicketCount is not a number", function () {
ticketCreate.TicketCount = "150";
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
"TicketCreate: TicketCount must be a number"
);
});
it ('throws when TicketCount is not an integer', () => {
ticketCreate.TicketCount = 12.5
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250'
)
})
it("throws when TicketCount is not an integer", function () {
ticketCreate.TicketCount = 12.5;
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
"TicketCreate: TicketCount must be an integer from 1 to 250"
);
});
it ('throws when TicketCount is < 1', () => {
ticketCreate.TicketCount = 0
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250'
)
})
it("throws when TicketCount is < 1", function () {
ticketCreate.TicketCount = 0;
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
"TicketCreate: TicketCount must be an integer from 1 to 250"
);
});
it ('throws when TicketCount is > 250', () => {
ticketCreate.TicketCount = 251
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250'
)
})
})
it("throws when TicketCount is > 250", function () {
ticketCreate.TicketCount = 251;
assert.throws(
() => verifyTicketCreate(ticketCreate),
ValidationError,
"TicketCreate: TicketCount must be an integer from 1 to 250"
);
});
});

View File

@@ -1,66 +1,68 @@
import { ValidationError } from 'xrpl-local/common/errors'
import { verifyTrustSet } from './../../src/models/transactions/trustSet'
import { assert } from 'chai'
import { assert } from "chai";
import { ValidationError } from "xrpl-local/common/errors";
import { verifyTrustSet } from "../../src/models/transactions/trustSet";
/**
* TrustSet Transaction Verification Testing
* TrustSet Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type
* Providing runtime verification testing for each specific transaction type.
*/
describe('TrustSet Transaction Verification', () => {
let trustSet
describe("TrustSet Transaction Verification", function () {
let trustSet;
beforeEach(() => {
trustSet = {
TransactionType: 'TrustSet',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
LimitAmount: {
currency: 'XRP',
issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
value: '4329.23'
},
QualityIn: 1234,
QualityOut: 4321,
} as any
})
beforeEach(function () {
trustSet = {
TransactionType: "TrustSet",
Account: "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
LimitAmount: {
currency: "XRP",
issuer: "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
value: "4329.23",
},
QualityIn: 1234,
QualityOut: 4321,
} as any;
});
it ('verifies valid TrustSet', () => {
assert.doesNotThrow(() => verifyTrustSet(trustSet))
})
it("verifies valid TrustSet", function () {
assert.doesNotThrow(() => verifyTrustSet(trustSet));
});
it ('throws when LimitAmount is missing', () => {
delete trustSet.LimitAmount
assert.throws(
() => verifyTrustSet(trustSet),
ValidationError,
'TrustSet: missing field LimitAmount'
)
})
it("throws when LimitAmount is missing", function () {
delete trustSet.LimitAmount;
assert.throws(
() => verifyTrustSet(trustSet),
ValidationError,
"TrustSet: missing field LimitAmount"
);
});
it ('throws when LimitAmount is invalid', () => {
trustSet.LimitAmount = 1234
assert.throws(
() => verifyTrustSet(trustSet),
ValidationError,
'TrustSet: invalid LimitAmount'
)
})
it("throws when LimitAmount is invalid", function () {
trustSet.LimitAmount = 1234;
assert.throws(
() => verifyTrustSet(trustSet),
ValidationError,
"TrustSet: invalid LimitAmount"
);
});
it ('throws when QualityIn is not a number', () => {
trustSet.QualityIn = '1234'
assert.throws(
() => verifyTrustSet(trustSet),
ValidationError,
'TrustSet: QualityIn must be a number'
)
})
it("throws when QualityIn is not a number", function () {
trustSet.QualityIn = "1234";
assert.throws(
() => verifyTrustSet(trustSet),
ValidationError,
"TrustSet: QualityIn must be a number"
);
});
it ('throws when QualityOut is not a number', () => {
trustSet.QualityOut = '4321'
assert.throws(
() => verifyTrustSet(trustSet),
ValidationError,
'TrustSet: QualityOut must be a number'
)
})
})
it("throws when QualityOut is not a number", function () {
trustSet.QualityOut = "4321";
assert.throws(
() => verifyTrustSet(trustSet),
ValidationError,
"TrustSet: QualityOut must be a number"
);
});
});

View File

@@ -1,29 +1,30 @@
import { isFlagEnabled } from '../../src/models/utils'
import { assert } from 'chai'
import { assert } from "chai";
import { isFlagEnabled } from "../../src/models/utils";
/**
* Utils Testing
* Utils Testing.
*
* Provides tests for utils used in models
* Provides tests for utils used in models.
*/
describe('Models Utils', () => {
describe('isFlagEnabled', () => {
let flags
const flag1 = 0x00010000
const flag2 = 0x00020000
describe("Models Utils", function () {
describe("isFlagEnabled", function () {
let flags;
const flag1 = 0x00010000;
const flag2 = 0x00020000;
beforeEach(() => {
flags = 0x00000000
})
beforeEach(function () {
flags = 0x00000000;
});
it('verifies a flag is enabled', () => {
flags += flag1 + flag2
assert.isTrue(isFlagEnabled(flags, flag1))
})
it("verifies a flag is enabled", function () {
flags += flag1 + flag2;
assert.isTrue(isFlagEnabled(flags, flag1));
});
it('verifies a flag is not enabled', () => {
flags += flag2
assert.isFalse(isFlagEnabled(flags, flag1))
})
})
})
it("verifies a flag is not enabled", function () {
flags += flag2;
assert.isFalse(isFlagEnabled(flags, flag1));
});
});
});