aboutsummaryrefslogtreecommitdiff
path: root/src/types-test.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-14 01:05:51 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-14 01:05:51 +0100
commit8ab5db6255ebea71dc6c839c2c7f00fa815a585e (patch)
treeae5b0fd452357549983c2fbcb60fdfa0aa54c0af /src/types-test.ts
parentdca6d303c1d15d49305f538dd62df7a65cdfcc38 (diff)
downloadwallet-core-8ab5db6255ebea71dc6c839c2c7f00fa815a585e.tar.xz
add contract validation test
Diffstat (limited to 'src/types-test.ts')
-rw-r--r--src/types-test.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/types-test.ts b/src/types-test.ts
index 3ebb1a5db..f8f25bc00 100644
--- a/src/types-test.ts
+++ b/src/types-test.ts
@@ -36,3 +36,38 @@ test("amount subtraction (saturation)", (t: TestLib) => {
t.assert(!res.saturated);
t.pass();
});
+
+
+test("contract validation", (t: TestLib) => {
+ let c = {
+ H_wire: "123",
+ summary: "hello",
+ amount: amt(1,2,"EUR"),
+ auditors: [],
+ pay_deadline: "Date(12346)",
+ max_fee: amt(1,2,"EUR"),
+ merchant_pub: "12345",
+ exchanges: [{master_pub: "foo", url: "foo"}],
+ products: [],
+ refund_deadline: "Date(12345)",
+ timestamp: "Date(12345)",
+ transaction_id: 1234,
+ fulfillment_url: "foo",
+ repurchase_correlation_id: "blabla",
+ };
+
+ types.Contract.checked(c);
+
+ let c1 = JSON.parse(JSON.stringify(c));
+ c1.exchanges = []
+
+ try {
+ types.Contract.checked(c1);
+ } catch (e) {
+ t.pass();
+ return;
+ }
+
+ t.fail();
+
+});