diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-11-14 01:05:51 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-11-14 01:05:51 +0100 |
commit | 8ab5db6255ebea71dc6c839c2c7f00fa815a585e (patch) | |
tree | ae5b0fd452357549983c2fbcb60fdfa0aa54c0af | |
parent | dca6d303c1d15d49305f538dd62df7a65cdfcc38 (diff) |
add contract validation test
-rw-r--r-- | src/types-test.ts | 35 |
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(); + +}); |