|
1 | 1 | import 'package:flutter_test/flutter_test.dart'; |
2 | 2 | import 'package:stackwallet/models/models.dart'; |
3 | 3 |
|
| 4 | +import '../services/coins/firo/sample_data/transaction_data_samples.dart'; |
| 5 | + |
4 | 6 | void main() { |
| 7 | + group("TransactionData", () { |
| 8 | + test("TransactionData from Json", () { |
| 9 | + final txChunk = TransactionChunk.fromJson({ |
| 10 | + "timestamp": 993260735, |
| 11 | + "transactions": [ |
| 12 | + { |
| 13 | + "txid": "txid", |
| 14 | + "confirmed_status": true, |
| 15 | + "timestamp": 1876352482, |
| 16 | + "txType": "txType", |
| 17 | + "amount": 10, |
| 18 | + "worthNow": "1", |
| 19 | + "worthAtBlockTimestamp": "1", |
| 20 | + "fees": 1, |
| 21 | + "inputSize": 1, |
| 22 | + "outputSize": 1, |
| 23 | + "inputs": [], |
| 24 | + "outputs": [], |
| 25 | + "address": "address", |
| 26 | + "height": 1, |
| 27 | + "confirmations": 1, |
| 28 | + "aliens": [], |
| 29 | + "subType": "mint", |
| 30 | + "isCancelled": false, |
| 31 | + "slateId": "slateId", |
| 32 | + "otherData": "otherData", |
| 33 | + } |
| 34 | + ] |
| 35 | + }); |
| 36 | + final txdata = |
| 37 | + TransactionData.fromJson({"dateTimeChunks": [], "txChunks": []}); |
| 38 | + txdata.findTransaction("txid"); |
| 39 | + txdata.getAllTransactions(); |
| 40 | + }); |
| 41 | + }); |
| 42 | + |
| 43 | + group("Timestamp", () { |
| 44 | + test("Timestamp is now", () { |
| 45 | + final date = extractDateFromTimestamp(0); |
| 46 | + }); |
| 47 | + |
| 48 | + test("Timestamp is null", () { |
| 49 | + final date = extractDateFromTimestamp(null); |
| 50 | + }); |
| 51 | + |
| 52 | + test("Timestamp is a random date", () { |
| 53 | + final date = extractDateFromTimestamp(1876352482); |
| 54 | + }); |
| 55 | + }); |
| 56 | + |
| 57 | + group("Transaction", () { |
| 58 | + test("Transaction from Json", () { |
| 59 | + final tx = Transaction.fromJson({ |
| 60 | + "txid": "txid", |
| 61 | + "confirmed_status": true, |
| 62 | + "timestamp": 1876352482, |
| 63 | + "txType": "txType", |
| 64 | + "amount": 10, |
| 65 | + "worthNow": "1", |
| 66 | + "worthAtBlockTimestamp": "1", |
| 67 | + "fees": 1, |
| 68 | + "inputSize": 1, |
| 69 | + "outputSize": 1, |
| 70 | + "inputs": [], |
| 71 | + "outputs": [], |
| 72 | + "address": "address", |
| 73 | + "height": 1, |
| 74 | + "confirmations": 1, |
| 75 | + "aliens": [], |
| 76 | + "subType": "mint", |
| 77 | + "isCancelled": false, |
| 78 | + "slateId": "slateId", |
| 79 | + "otherData": "otherData", |
| 80 | + }); |
| 81 | + }); |
| 82 | + |
| 83 | + test("Transaction from Lelantus Json", () { |
| 84 | + final tx = Transaction.fromLelantusJson({ |
| 85 | + "txid": "txid", |
| 86 | + "confirmed_status": true, |
| 87 | + "timestamp": 1876352482, |
| 88 | + "txType": "txType", |
| 89 | + "amount": 10, |
| 90 | + "worthNow": "1", |
| 91 | + "worthAtBlockTimestamp": "1", |
| 92 | + "fees": 1, |
| 93 | + "inputSize": 1, |
| 94 | + "outputSize": 1, |
| 95 | + "inputs": [], |
| 96 | + "outputs": [], |
| 97 | + "address": "address", |
| 98 | + "height": 1, |
| 99 | + "confirmations": 1, |
| 100 | + "aliens": [], |
| 101 | + "subType": "mint", |
| 102 | + "isCancelled": false, |
| 103 | + "slateId": "slateId", |
| 104 | + "otherData": "otherData", |
| 105 | + }); |
| 106 | + }); |
| 107 | + |
| 108 | + test("TransactionChunk", () { |
| 109 | + final transactionchunk = TransactionChunk.fromJson({ |
| 110 | + "timestamp": 45920, |
| 111 | + "transactions": [], |
| 112 | + }); |
| 113 | + expect( |
| 114 | + transactionchunk.toString(), "timestamp: 45920 transactions: [\n]"); |
| 115 | + }); |
| 116 | + |
| 117 | + test("TransactionChunk with a transaction", () { |
| 118 | + final txChunk = TransactionChunk.fromJson({ |
| 119 | + "timestamp": 993260735, |
| 120 | + "transactions": [ |
| 121 | + { |
| 122 | + "txid": "txid", |
| 123 | + "confirmed_status": true, |
| 124 | + "timestamp": 1876352482, |
| 125 | + "txType": "txType", |
| 126 | + "amount": 10, |
| 127 | + "worthNow": "1", |
| 128 | + "worthAtBlockTimestamp": "1", |
| 129 | + "fees": 1, |
| 130 | + "inputSize": 1, |
| 131 | + "outputSize": 1, |
| 132 | + "inputs": [], |
| 133 | + "outputs": [], |
| 134 | + "address": "address", |
| 135 | + "height": 1, |
| 136 | + "confirmations": 1, |
| 137 | + "aliens": [], |
| 138 | + "subType": "mint", |
| 139 | + "isCancelled": false, |
| 140 | + "slateId": "slateId", |
| 141 | + "otherData": "otherData", |
| 142 | + } |
| 143 | + ] |
| 144 | + }); |
| 145 | + expect(txChunk.toString(), |
| 146 | + "timestamp: 993260735 transactions: [\n {txid: txid, type: txType, subType: mint, value: 10, fee: 1, height: 1, confirm: true, confirmations: 1, address: address, timestamp: 1876352482, worthNow: 1, inputs: [], slateid: slateId } \n]"); |
| 147 | + }); |
| 148 | + }); |
| 149 | + |
5 | 150 | group("Transaction isMinting", () { |
6 | 151 | test("Transaction isMinting unconfirmed mint", () { |
7 | 152 | final tx = Transaction( |
@@ -94,4 +239,57 @@ void main() { |
94 | 239 | expect(tx1 == tx2, false); |
95 | 240 | expect(tx2.toString(), tx1.toString()); |
96 | 241 | }); |
| 242 | + |
| 243 | + group("Input", () { |
| 244 | + test("Input.toString", () { |
| 245 | + final input = Input( |
| 246 | + txid: "txid", |
| 247 | + vout: 1, |
| 248 | + prevout: null, |
| 249 | + scriptsig: "scriptsig", |
| 250 | + scriptsigAsm: "scriptsigAsm", |
| 251 | + witness: [], |
| 252 | + isCoinbase: false, |
| 253 | + sequence: 1, |
| 254 | + innerRedeemscriptAsm: "innerRedeemscriptAsm", |
| 255 | + ); //Input |
| 256 | + |
| 257 | + expect(input.toString(), "{txid: txid}"); |
| 258 | + }); |
| 259 | + |
| 260 | + test("Input.toString", () { |
| 261 | + final input = Input.fromJson({ |
| 262 | + "txid": "txid", |
| 263 | + "vout": 1, |
| 264 | + "prevout": null, |
| 265 | + "scriptSig": {"hex": "somehexString", "asm": "someasmthing"}, |
| 266 | + "scriptsigAsm": "scriptsigAsm", |
| 267 | + "witness": [], |
| 268 | + "isCoinbase": false, |
| 269 | + "sequence": 1, |
| 270 | + "innerRedeemscriptAsm": "innerRedeemscriptAsm", |
| 271 | + }); //Input |
| 272 | + |
| 273 | + expect(input.toString(), "{txid: txid}"); |
| 274 | + }); |
| 275 | + }); |
| 276 | + |
| 277 | + group("Output", () { |
| 278 | + test("Output.toString", () { |
| 279 | + final output = Output.fromJson({ |
| 280 | + "scriptPubKey": { |
| 281 | + "hex": "somehexSting", |
| 282 | + "asm": "someasmthing", |
| 283 | + "type": "sometype", |
| 284 | + "addresses": "someaddresses", |
| 285 | + }, |
| 286 | + "scriptpubkeyAsm": "scriptpubkeyAsm", |
| 287 | + "scriptpubkeyType": "scriptpubkeyType", |
| 288 | + "scriptpubkeyAddress": "address", |
| 289 | + "value": 2, |
| 290 | + }); //Input |
| 291 | + |
| 292 | + expect(output.toString(), "Instance of \'Output\'"); |
| 293 | + }); |
| 294 | + }); |
97 | 295 | } |
0 commit comments