-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_meta_dex_plan.py
executable file
·1584 lines (1342 loc) · 67.9 KB
/
test_meta_dex_plan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python2
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from framework_extension import MasterTestFramework
from framework_entity import TestEntity
from framework_info import TestInfo
# Helper
BTC = 0
MSC = 1
TMSC = 2
TIndiv1 = 2147483651
TIndiv2 = 2147483652
TIndiv3 = 2147483653
TIndivMax = 2147483654
TDiv1 = 2147483655
TDiv2 = 2147483656
TDiv3 = 2147483657
TDivMax = 2147483658
ADD_1 = 1
CANCEL_2 = 2
CANCEL_3 = 3
CANCEL_4 = 4
class MetaDexPlanTest(MasterTestFramework):
"""Python version of the MetaDEx testplan spreadsheed:
https://docs.google.com/spreadsheets/d/1oL2jGfG3BwslURyDTYNvM6Z2p79ux46NmwcXDYleEbg/edit#gid=0
Note: the RPC "trade_MP" is going to be depreciated and split into:
- "omni_sendtrade"
- "omni_sendcanceltradesbyprice"
- "omni_sendcanceltradesbypair"
- "omni_sendcancelalltrades"
However, "trade_MP" remains to be part of Omni Core for now, and simply acts as forwarder."""
def run_test(self):
self.entities = [TestEntity(node) for node in self.nodes]
self.prepare_funding()
self.prepare_properties()
self.initial_distribution()
self.test_invalid_action()
self.test_invalid_cancel_everything_no_active_offers()
self.test_invalid_cancel_pair_no_active_offers()
self.test_invalid_cancel_no_active_offers()
self.test_invalid_add_same_currency()
self.test_invalid_add_zero_amount()
self.test_invalid_add_bitcoin()
self.test_invalid_add_cross_ecosystem()
self.test_invalid_insufficient_balance()
self.test_invalid_amount_too_large()
self.test_invalid_amount_negative()
self.test_new_orders_for_divisible()
self.test_match_divisible_at_same_unit_price()
self.test_match_divisible_at_better_unit_price()
self.test_match_divisible_with_three()
self.test_match_large_and_small_amounts()
self.test_new_orders_for_indivisible()
self.test_match_indivisible_at_same_unit_price()
self.test_match_indivisible_at_better_unit_price()
self.test_match_indivisible_with_three()
self.success = TestInfo.Status()
def prepare_funding(self):
"""A1, A2, A3 (node 2-4) are funded with 50.0 BTC each.
The miner (node 1) furthermore purchases 50000.0 MSC and 50000.0 TMSC.
Those tokens are not yet distributed and used later.
MSC and TMSC balance of the miner is tested."""
entity_miner = self.entities[0]
entity_a1 = self.entities[1]
entity_a2 = self.entities[2]
entity_a3 = self.entities[3]
entity_miner.send_bitcoins(entity_miner.address)
entity_miner.send_bitcoins(entity_a1.address, 50.0)
entity_miner.send_bitcoins(entity_a2.address, 50.0)
entity_miner.send_bitcoins(entity_a3.address, 50.0)
entity_miner.purchase_mastercoins(500.0)
self.generate_block()
self.check_balance(entity_miner.address, MSC, '50000.00000000', '0.00000000')
self.check_balance(entity_miner.address, TMSC, '50000.00000000', '0.00000000')
def prepare_properties(self):
"""The miner (node 1) creates 8 new properties with the maximum amounts possible.
4 with divisible units: TDiv1, TDiv2, TDiv3, TDivMax
4 with indivisible units: TIndiv1, TIndiv2, TIndiv3, TIndivMax
The tokens are going to be distributed as needed.
Final balances of miner (node 1) are tested to confirm correct property creation."""
node = self.entities[0].node
addr = self.entities[0].address
if len(node.omni_listproperties()) > 2:
AssertionError('There should not be more than two properties, MSC and TMSC, after a clean start')
# tx: 50, ecosystem: 2, 9223372036854775807 indivisible tokens, "TIndiv1"
node.omni_sendrawtx(addr, '0000003202000100000000000054496e646976310000007fffffffffffffff')
# tx: 50, ecosystem: 2, 9223372036854775807 indivisible tokens, "TIndiv2"
node.omni_sendrawtx(addr, '0000003202000100000000000054496e646976320000007fffffffffffffff')
# tx: 50, ecosystem: 2, 9223372036854775807 indivisible tokens, "TIndiv3"
node.omni_sendrawtx(addr, '0000003202000100000000000054496e646976330000007fffffffffffffff')
# tx: 50, ecosystem: 2, 9223372036854775807 indivisible tokens, "TIndivMax"
node.omni_sendrawtx(addr, '0000003202000100000000000054496e6469764d61780000007fffffffffffffff')
# tx: 50, ecosystem: 2, 92233720368.54770000 divisible tokens, "TDiv1"
node.omni_sendrawtx(addr, '0000003202000200000000000054446976310000007fffffffffffffff')
# tx: 50, ecosystem: 2, 92233720368.54770000 divisible tokens, "TDiv2"
node.omni_sendrawtx(addr, '0000003202000200000000000054446976320000007fffffffffffffff')
# tx: 50, ecosystem: 2, 92233720368.54770000 divisible tokens, "TDiv3"
node.omni_sendrawtx(addr, '0000003202000200000000000054446976330000007fffffffffffffff')
# tx: 50, ecosystem: 2, 92233720368.54770000 divisible tokens, "TDivMax"
node.omni_sendrawtx(addr, '00000032020002000000000000544469764d61780000007fffffffffffffff')
self.generate_block()
self.check_balance(addr, TIndiv1, '9223372036854775807', '0')
self.check_balance(addr, TIndiv2, '9223372036854775807', '0')
self.check_balance(addr, TIndiv3, '9223372036854775807', '0')
self.check_balance(addr, TIndivMax, '9223372036854775807', '0')
self.check_balance(addr, TDiv1, '92233720368.54775807', '0.00000000')
self.check_balance(addr, TDiv2, '92233720368.54775807', '0.00000000')
self.check_balance(addr, TDiv3, '92233720368.54775807', '0.00000000')
self.check_balance(addr, TDivMax, '92233720368.54775807', '0.00000000')
def initial_distribution(self):
"""Tokens are sent from the miner (node 1) to A1, A2, A3 (node 2-4).
Final balances are tested."""
entity_miner = self.entities[0]
entity_a1 = self.entities[1]
entity_a2 = self.entities[2]
entity_a3 = self.entities[3]
entity_miner.send(entity_a1.address, TMSC, '150.00000000')
entity_miner.send(entity_a2.address, TMSC, '50.00000000')
entity_miner.send(entity_a3.address, TMSC, '25.00000000')
entity_miner.send(entity_a1.address, TDiv1, '100.00000000')
entity_miner.send(entity_a2.address, TDiv1, '50.00000000')
# A3 does not receive any TDiv1
# A1 does not receive any TDiv2
entity_miner.send(entity_a2.address, TDiv2, '200.00000000')
# A3 does not receive any TDiv2
# A1 does not receive any TDiv3
entity_miner.send(entity_a2.address, TDiv3, '200.00000000')
entity_miner.send(entity_a3.address, TDiv3, '200.00000000')
# A1 does not receive any TDivMax
# A2 does not receive any TDivMax
entity_miner.send(entity_a3.address, TDivMax, '92233720368.54775807')
entity_miner.send(entity_a1.address, TIndiv1, '1000')
entity_miner.send(entity_a2.address, TIndiv1, '50')
# A3 does not receive any TIndiv1
# A1 does not receive any TIndiv2
entity_miner.send(entity_a2.address, TIndiv2, '2000')
# A3 does not receive any TIndiv2
# A1 does not receive any TIndiv3
entity_miner.send(entity_a2.address, TIndiv3, '200')
entity_miner.send(entity_a3.address, TIndiv3, '200')
# A1 does not receive any TIndivMax
# A2 does not receive any TIndivMax
entity_miner.send(entity_a3.address, TIndivMax, '9223372036854775807')
self.generate_block()
self.check_balance(entity_a1.address, TMSC, '150.00000000', '0.00000000')
self.check_balance(entity_a2.address, TMSC, '50.00000000', '0.00000000')
self.check_balance(entity_a3.address, TMSC, '25.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '100.00000000', '0.00000000')
self.check_balance(entity_a2.address, TDiv1, '50.00000000', '0.00000000')
self.check_balance(entity_a3.address, TDiv1, '0.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv2, '0.00000000', '0.00000000')
self.check_balance(entity_a2.address, TDiv2, '200.00000000', '0.00000000')
self.check_balance(entity_a3.address, TDiv2, '0.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv3, '0.00000000', '0.00000000')
self.check_balance(entity_a2.address, TDiv3, '200.00000000', '0.00000000')
self.check_balance(entity_a3.address, TDiv3, '200.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDivMax, '0.00000000', '0.00000000')
self.check_balance(entity_a2.address, TDivMax, '0.00000000', '0.00000000')
self.check_balance(entity_a3.address, TDivMax, '92233720368.54775807', '0.00000000')
self.check_balance(entity_a1.address, TIndiv1, '1000', '0')
self.check_balance(entity_a2.address, TIndiv1, '50', '0')
self.check_balance(entity_a3.address, TIndiv1, '0', '0')
self.check_balance(entity_a1.address, TIndiv2, '0', '0')
self.check_balance(entity_a2.address, TIndiv2, '2000', '0')
self.check_balance(entity_a3.address, TIndiv2, '0', '0')
self.check_balance(entity_a1.address, TIndiv3, '0', '0')
self.check_balance(entity_a2.address, TIndiv3, '200', '0')
self.check_balance(entity_a3.address, TIndiv3, '200', '0')
self.check_balance(entity_a1.address, TIndivMax, '0', '0')
self.check_balance(entity_a2.address, TIndivMax, '0', '0')
self.check_balance(entity_a3.address, TIndivMax, '9223372036854775807', '0')
def check_invalid(self, reason='none provided', txid=''):
tx_rejected = (len(txid) != 64 or txid == '0000000000000000000000000000000000000000000000000000000000000000')
if tx_rejected:
print('Transaction rejected (reason: %s) ... OK' % (reason,))
return True
self.generate_block()
tx = self.nodes[0].omni_gettransaction(txid)
tx_invalid = (not tx['valid'])
if tx_invalid:
print('Transaction invalid (reason: %s) ... OK' % (reason,))
return True
# Otherwise the transaction is valid and therefore this check failed
raise AssertionError(
'Expected transaction to be invalid (reason: %s):\nTransaction hash: %s\n%s\n%s\n' % (
reason, txid, str(tx), self.nodes[0].getrawtransaction(txid),))
# A21 is not coded
# A22-23
def test_invalid_action(self):
"""Tests invalidation of orders with non-existing subaction values.
The data is submitted via RPC command trade_MP."""
entity_a1 = self.entities[1]
TestInfo.ExpectFail()
try: txid_a22 = entity_a1.trade('2.00000000', TMSC, '2.00000000', TDiv1, 0)
except: txid_a22 = '0'
self.check_invalid('invalid action (0)', txid_a22)
try: txid_a23 = entity_a1.trade('2.00000000', TMSC, '2.00000000', TDiv1, 5)
except: txid_a23 = '0'
self.check_invalid('invalid action (5)', txid_a23)
TestInfo.StopExpectation()
# NOTE: Invalidation tests should be done via trade_MP, but also via raw transactions, to get around input filters.
# A24
def test_invalid_cancel_everything_no_active_offers(self):
"""Tests invalidation of transactions with CANCEL-EVERYTHING command, but no active, matching offers."""
entity_a1 = self.entities[1]
TestInfo.ExpectFail()
try: txid_a24_1 = entity_a1.trade('2.00000000', TMSC, '2.00000000', TDiv1, CANCEL_4)
except: txid_a24_1 = '0'
self.check_invalid('no active orders, cancel-everything, positive amounts, test ecosystem', txid_a24_1)
try: txid_a24_2 = entity_a1.trade('2.00000000', TMSC, '2.00000000', TMSC, CANCEL_4)
except: txid_a24_2 = '0'
self.check_invalid('no active orders, cancel-everything, positive amounts, TMSC, TMSC (!)', txid_a24_2)
try: txid_a24_3 = entity_a1.trade('2.00000000', MSC, '2.00000000', TMSC, CANCEL_4)
except: txid_a24_3 = '0'
self.check_invalid('no active orders, cancel-everything, positive amounts, cross ecosystem (!)', txid_a24_3)
try: txid_a24_4 = entity_a1.trade('2.00000000', 67, '2.00000000', 68, CANCEL_4)
except: txid_a24_4 = '0'
self.check_invalid('no active orders, cancel-everything, positive amounts, non-existing pair (!)', txid_a24_4)
try: txid_a24_5 = entity_a1.trade('0.00000000', TMSC, '0.00000000', TDiv1, CANCEL_4)
except: txid_a24_5 = '0'
self.check_invalid('no active orders, cancel-everything, zero amounts (!), test ecosystem', txid_a24_5)
try: txid_a24_6 = entity_a1.trade('0.00000000', TMSC, '0.00000000', TMSC, CANCEL_4)
except: txid_a24_6 = '0'
self.check_invalid('no active orders, cancel-everything, zero amounts (!), TMSC, TMSC (!)', txid_a24_6)
try: txid_a24_7 = entity_a1.trade('0.00000000', MSC, '0.00000000', TMSC, CANCEL_4)
except: txid_a24_7 = '0'
self.check_invalid('no active orders, cancel-everything, zero amounts (!), cross ecosystem (!)', txid_a24_7)
try: txid_a24_8 = entity_a1.trade('0.00000000', 67, '0.00000000', 68, CANCEL_4)
except: txid_a24_8 = '0'
self.check_invalid('no active orders, cancel-everything, zero amounts (!), non-existing pair (!)', txid_a24_8)
TestInfo.StopExpectation()
# A25-26
def test_invalid_cancel_pair_no_active_offers(self):
"""Tests invalidation of transactions with CANCEL-PAIR command, but no active, matching offers."""
entity_a1 = self.entities[1]
TestInfo.ExpectFail()
try: txid_a25 = entity_a1.trade('2.00000000', TMSC, '2.00000000', TDiv1, CANCEL_3)
except: txid_a25 = '0'
self.check_invalid('no active orders for currency pair', txid_a25)
try: txid_a26 = entity_a1.trade('2.00000000', TDiv1, '2.00000000', TMSC, CANCEL_3)
except: txid_a26 = '0'
self.check_invalid('no active orders for currency pair', txid_a26)
TestInfo.StopExpectation()
# A27-28
def test_invalid_cancel_no_active_offers(self):
""""Tests invalidation of transactions with CANCEL command, but no active, matching offers."""
entity_a1 = self.entities[1]
TestInfo.ExpectFail()
try: txid_a27 = entity_a1.trade('2.00000000', TDiv2, '2.00000000', TMSC, CANCEL_2)
except: txid_a27 = '0'
self.check_invalid('no active orders for currency pair and price', txid_a27)
try: txid_a28 = entity_a1.trade('2.00000000', TMSC, '2.00000000', TDiv2, CANCEL_2)
except: txid_a28 = '0'
self.check_invalid('no active orders for currency pair and price', txid_a28)
TestInfo.StopExpectation()
# A29-30
def test_invalid_add_same_currency(self):
"""Tests invalidation of transactions with the same property on both sides of an offer."""
entity_a1 = self.entities[1]
TestInfo.ExpectFail()
try: txid_a29 = entity_a1.trade('1.00000000', TDiv1, '2.00000000', TDiv1, ADD_1)
except: txid_a29 = '0'
self.check_invalid('same currency (and neither is TMSC)', txid_a29)
try: txid_a30 = entity_a1.trade('1.00000000', TMSC, '2.00000000', TMSC, ADD_1)
except: txid_a30 = '0'
self.check_invalid('same currency', txid_a30)
TestInfo.StopExpectation()
# A31-32
def test_invalid_add_zero_amount(self):
"""Tests invalidation of offers with zero amounts."""
entity_a1 = self.entities[1]
TestInfo.ExpectFail()
try: txid_a31 = entity_a1.trade('0.00000000', TDiv1, '1.00000000', TMSC, ADD_1)
except: txid_a31 = '0'
self.check_invalid('amount for sale is 0.0', txid_a31)
try: txid_a32 = entity_a1.trade('1.00000000', TDiv1, '0.00000000', TMSC, ADD_1)
except: txid_a32 = '0'
self.check_invalid('amount desired is 0.0', txid_a32)
TestInfo.StopExpectation()
# A33-34
def test_invalid_add_bitcoin(self):
"""Tests invalidation of offers with bitcoin."""
entity_a1 = self.entities[1]
TestInfo.ExpectFail()
try: txid_a33 = entity_a1.trade('1.00000000', BTC, '1.00000000', TMSC, ADD_1)
except: txid_a33 = '0'
self.check_invalid('desired property is bitcoin', txid_a33)
try: txid_a34 = entity_a1.trade('1.00000000', TMSC, '1.00000000', BTC, ADD_1)
except: txid_a34 = '0'
self.check_invalid('property for sale is bitcoin', txid_a34)
TestInfo.StopExpectation()
# A35-36
def test_invalid_add_cross_ecosystem(self):
"""Tests invalidation of offers with properties that are not in the same ecosystem."""
entity_a1 = self.entities[1]
TestInfo.ExpectFail()
try: txid_a35 = entity_a1.trade('1.00000000', MSC, '1.00000000', TDiv1, ADD_1)
except: txid_a35 = '0'
self.check_invalid('cross ecosystem (main, test) (MSC, TDiv1)', txid_a35)
try: txid_a36 = entity_a1.trade('1.00000000', TDiv1, '1.00000000', MSC, ADD_1)
except: txid_a36 = '0'
self.check_invalid('cross ecosystem (test, main) (MSC, TDiv1)', txid_a36)
TestInfo.StopExpectation()
# A38-41
def test_invalid_insufficient_balance(self):
"""Tests invalidation of offers due to insufficient balance."""
entity_a1 = self.entities[1]
TestInfo.ExpectFail()
try: txid_a38 = entity_a1.trade('1', TIndiv2, '1.00000000', TMSC, ADD_1)
except: txid_a38 = '0'
self.check_invalid('A1 does not have any TIndiv2', txid_a38)
try: txid_a39 = entity_a1.trade('2001', TIndiv1, '1.00000000', TMSC, ADD_1)
except: txid_a39 = '0'
self.check_invalid('A1 does not have enough TIndiv1', txid_a39)
try: txid_a40 = entity_a1.trade('1.00000000', TDiv2, '1.00000000', TMSC, ADD_1)
except: txid_a40 = '0'
self.check_invalid('A1 does not have any TDiv2', txid_a40)
try: txid_a41 = entity_a1.trade('100.00000001', TDiv1, '1.00000000', TMSC, ADD_1)
except: txid_a41 = '0'
self.check_invalid('A1 does not have enough TDiv1', txid_a41)
TestInfo.StopExpectation()
# NOTE: The following tests do not reflect the test plan strictly, because there are no negative amounts
# when using unsigned numbers.
def test_invalid_amount_too_large(self):
"""Tests invalidation of offers with amounts that are out of range.
NOTE: a different number than max. + 1 (9223372036854775808, 92233720368.54775808) was chosen,
because max. + 1, represented as unsigned integer 0x8000000000000000..
The data is submitted via RPC command trade_MP."""
entity_a1 = self.entities[1]
entity_a3 = self.entities[3]
# TODO: StrToInt64, which is used in trade_MP, parses out-of-range amounts as 0.
TestInfo.ExpectFail()
try: txid_a42 = entity_a1.trade('0.00000001', TDiv1, '92233720368.54780000', TMSC, ADD_1)
except: txid_a42 = '0'
self.check_invalid('amount desired is too large (92233720368.54780000 TMSC)', txid_a42)
try: txid_a43 = entity_a3.trade('92233720368.54780000', TDivMax, '0.00000001', TMSC, ADD_1)
except: txid_a43 = '0'
self.check_invalid('amount for sale is too large (92233720368.54780000 TDivMax)', txid_a43)
try: txid_a44 = entity_a1.trade('1', TIndiv1, '92233720368.54780000', TMSC, ADD_1)
except: txid_a44 = '0'
self.check_invalid('amount desired is too large (92233720368.54780000 TMSC)', txid_a44)
try: txid_a45 = entity_a3.trade('9223372036854780000', TIndivMax, '0.00000001', TMSC, ADD_1)
except: txid_a45 = '0'
self.check_invalid('amount for sale is too large (9223372036854780000 TIndivMax)', txid_a45)
try: txid_a46 = entity_a1.trade('92233720368.54780000', TMSC, '92233720368.54780000', TDiv1, ADD_1)
except: txid_a46 = '0'
self.check_invalid('both amounts are too large', txid_a46)
try: txid_a47 = entity_a1.trade('92233720368.54780000', TMSC, '9223372036854780000', TIndiv1, ADD_1)
except: txid_a47 = '0'
self.check_invalid('both amounts are too large', txid_a47)
TestInfo.StopExpectation()
def test_invalid_amount_negative(self):
"""Tests invalidation of offers with negative amounts."""
entity_a1 = self.entities[1]
entity_a3 = self.entities[3]
# NOTE: StrToInt64, which is used in trade_MP, parses negative amounts as 0.
TestInfo.ExpectFail()
try: txid_a48 = entity_a1.trade('0.00000001', TDiv1, '-0.00000001', TMSC, ADD_1)
except: txid_a48 = '0'
self.check_invalid('amount desired is negative (-0.00000001 TMSC)', txid_a48)
try: txid_a49 = entity_a3.trade('-0.00000001', TDivMax, '0.00000001', TMSC, ADD_1)
except: txid_a49 = '0'
self.check_invalid('amount for sale is negative (-0.00000001 TDivMax)', txid_a49)
try: txid_a50 = entity_a1.trade('1', TIndiv1, '-0.00000001', TMSC, ADD_1)
except: txid_a50 = '0'
self.check_invalid('amount desired is negative (-0.00000001 TMSC)', txid_a50)
try: txid_a51 = entity_a3.trade('-1', TIndivMax, '0.00000001', TMSC, ADD_1)
except: txid_a51 = '0'
self.check_invalid('amount for sale is negative (-1 TIndivMax)', txid_a51)
try: txid_a52 = entity_a1.trade('-0.00000001', TMSC, '-0.00000001', TDiv1, ADD_1)
except: txid_a52 = '0'
self.check_invalid('both amounts are negative (-0.00000001 TMSC, -0.00000001 TDiv1)', txid_a52)
try: txid_a53 = entity_a1.trade('-0.00000001', TMSC, '-1', TIndiv1, ADD_1)
except: txid_a53 = '0'
self.check_invalid('both amounts are negative (-0.00000001 TMSC,-1 TIndiv1)', txid_a53)
TestInfo.StopExpectation()
# A59-65
def test_new_orders_for_divisible(self):
"""Tests creation of offers with divisible amounts.
There is also one invalid attempt to cancel an offer where no active order for that pair and price exists."""
entity_a1 = self.entities[1]
self.check_balance(entity_a1.address, TMSC, '150.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '100.00000000', '0.00000000')
self.check_balance(entity_a1.address, TIndiv1, '1000', '0')
# A59
entity_a1.trade('10.00000000', TDiv1, '10.00000000', TMSC)
self.generate_block()
#
#
# A1: SELL 10.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 10.00000000 TMSC) << added
#
#
self.check_balance(entity_a1.address, TMSC, '150.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '90.00000000', '10.00000000')
self.check_balance(entity_a1.address, TIndiv1, '1000', '0')
TestInfo.ExpectFail()
# A60
try: txid_a60 = entity_a1.trade('10.00000001', TMSC, '9.99999999', TDiv1, CANCEL_2)
except: txid_a60 = '0'
self.check_invalid('no active orders for that pair and price', txid_a60)
TestInfo.StopExpectation()
# A61
entity_a1.trade('3.00000000', TDiv1, '3.00000000', TMSC)
self.generate_block()
#
#
# A1: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC) << added
# A1: SELL 10.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 10.00000000 TMSC)
#
#
self.check_balance(entity_a1.address, TMSC, '150.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '87.00000000', '13.00000000')
# A63
entity_a1.trade('1.00000000', TDiv1, '0.00000001', TMSC)
self.generate_block()
#
#
# A1: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
# A1: SELL 10.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 10.00000000 TMSC)
# A1: SELL 1.00000000 TDiv1 @ 0.00000001 TMSC/TDiv1 (total: 0.00000001 TMSC) << added
#
#
self.check_balance(entity_a1.address, TMSC, '150.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '86.00000000', '14.00000000')
# A64
entity_a1.trade('5', TIndiv1, '6.00000000', TMSC)
self.generate_block()
#
#
# A1: SELL 5 TIndiv1 @ 1.20000000 TMSC/TIndiv1 (total: 6.0 TMSC) << added
#
#
self.check_balance(entity_a1.address, TMSC, '150.00000000', '0.00000000')
self.check_balance(entity_a1.address, TIndiv1, '995', '5')
# A65
entity_a1.trade('1.00000000', TDiv1, '0.00000001', TMSC, CANCEL_2)
self.generate_block()
#
#
# A1: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
# A1: SELL 10.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 10.00000000 TMSC)
# A1: SELL 1.00000000 TDiv1 @ 0.00000001 TMSC/TDiv1 (total: 0.00000001 TMSC)
#
# A1: CANCEL 1.00000000 TDiv1 @ 0.00000001 TMSC/TDiv1 (total: 0.00000001 TMSC) << pending
#
# =>
#
# A1: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
# A1: SELL 10.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 10.00000000 TMSC)
#
#
self.check_balance(entity_a1.address, TMSC, '150.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '87.00000000', '13.00000000')
# A68-74
def test_match_divisible_at_same_unit_price(self):
"""Tests matching and execution of orders at the same unit price.
There is also one invalid attempt to cancel an offer where no active order for that pair and price exists."""
entity_a1 = self.entities[1]
entity_a2 = self.entities[2]
entity_a3 = self.entities[3]
self.check_balance(entity_a1.address, TMSC, '150.00000000', '0.00000000')
self.check_balance(entity_a2.address, TMSC, '50.00000000', '0.00000000')
self.check_balance(entity_a3.address, TMSC, '25.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '87.00000000', '13.00000000')
self.check_balance(entity_a2.address, TDiv1, '50.00000000', '0.00000000')
self.check_balance(entity_a3.address, TDiv1, '0.00000000', '0.00000000')
# A68
entity_a1.trade('1.00000000', TMSC, '1.00000000', TDiv1)
self.generate_block()
#
#
# A1: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
# A1: SELL 10.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 10.00000000 TMSC)
#
# A1; BUY 1.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 1.00000000 TMSC) << pending
#
# =>
#
# A1 BUYS 1.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 1.00000000 TMSC)
#
# =>
#
# A1: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
# A1: SELL 9.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 9.00000000 TMSC) << updated
#
#
# Movements:
# A1->A1: 1.00000000 TMSC, A1->A1: 1.00000000 TDiv1
#
self.check_balance(entity_a1.address, TMSC, '150.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '88.00000000', '12.00000000')
# A69
entity_a2.trade('1.00000000', TMSC, '1.00000000', TDiv1)
self.generate_block()
#
#
# A1: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
# A1: SELL 9.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 9.00000000 TMSC)
#
# A2; BUY 1.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 1.00000000 TMSC) << pending
#
# =>
#
# A2 BUYS 1.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 1.00000000 TMSC)
#
# =>
#
# A1: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
# A1: SELL 8.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 8.00000000 TMSC) << updated
#
#
# Movements:
# A2->A1: 1.00000000 TMSC, A1->A2: 1.00000000 TDiv1
#
self.check_balance(entity_a1.address, TMSC, '151.00000000', '0.00000000')
self.check_balance(entity_a2.address, TMSC, '49.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '88.00000000', '11.00000000')
self.check_balance(entity_a2.address, TDiv1, '51.00000000', '0.00000000')
# A71
entity_a2.trade('6.00000000', TDiv1, '6.00000000', TMSC)
self.generate_block()
#
#
# A2: SELL 6.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 6.00000000 TMSC) << added
# A1: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
# A1: SELL 8.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 8.00000000 TMSC)
#
#
self.check_balance(entity_a1.address, TMSC, '151.00000000', '0.00000000')
self.check_balance(entity_a2.address, TMSC, '49.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '88.00000000', '11.00000000')
self.check_balance(entity_a2.address, TDiv1, '45.00000000', '6.00000000')
# A73
entity_a3.trade('0.50000000', TMSC, '0.50000000', TDiv1)
self.generate_block()
#
#
# A2: SELL 6.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 6.00000000 TMSC)
# A1: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
# A1: SELL 8.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 8.00000000 TMSC)
#
# A3; BUY 0.50000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 0.50000000 TMSC) << pending
#
# =>
#
# A3 BUYS 0.50000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 0.50000000 TMSC)
#
# =>
#
# A2: SELL 6.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 6.00000000 TMSC)
# A1: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
# A1: SELL 7.50000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 7.50000000 TMSC) << updated
#
#
# Movements:
# A3->A1: 0.50000000 TMSC, A1->A3: 0.50000000 TDiv1
#
self.check_balance(entity_a1.address, TMSC, '151.50000000', '0.00000000')
self.check_balance(entity_a3.address, TMSC, '24.50000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '88.00000000', '10.50000000')
self.check_balance(entity_a3.address, TDiv1, '0.50000000', '0.00000000')
# A74
entity_a3.trade('11.50000000', TMSC, '11.50000000', TDiv1)
self.generate_block()
#
#
# A2: SELL 6.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 6.00000000 TMSC)
# A1: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
# A1: SELL 7.50000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 7.50000000 TMSC)
#
# A3; BUY 11.50000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 11.50000000 TMSC) << pending
#
# =>
#
# A3 BUYS 7.50000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 7.50000001 TMSC)
# A3 BUYS 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
# A3 BUYS 1.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 1.00000000 TMSC)
#
# =>
#
# A2: SELL 5.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 5.00000000 TMSC) << updated
#
#
# Movements:
# A3->A1: 7.50000000 TMSC, A1->A3: 7.50000000 TDiv1
# A3->A1: 3.00000000 TMSC, A1->A3: 3.00000000 TDiv1
# A3->A2: 1.00000000 TMSC, A2->A3: 1.00000000 TDiv1
#
self.check_balance(entity_a1.address, TMSC, '162.00000000', '0.00000000')
self.check_balance(entity_a2.address, TMSC, '50.00000000', '0.00000000')
self.check_balance(entity_a3.address, TMSC, '13.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '88.00000000', '0.00000000')
self.check_balance(entity_a2.address, TDiv1, '45.00000000', '5.00000000')
self.check_balance(entity_a3.address, TDiv1, '12.00000000', '0.00000000')
# A77-80
def test_match_divisible_at_better_unit_price(self):
"""Tests matching and execution of orders at a better unit price.
There is also one valid CANCEL operation."""
entity_a1 = self.entities[1]
entity_a2 = self.entities[2]
entity_a3 = self.entities[3]
#
# Orderbook:
#
# A1: SELL 5 TIndiv1 @ 1.20000000 TMSC/TIndiv1 (total: 6.0 TMSC)
#
# A2: SELL 5.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 5.00000000 TMSC)
#
#
self.check_balance(entity_a1.address, TMSC, '162.00000000', '0.00000000')
self.check_balance(entity_a2.address, TMSC, '50.00000000', '0.00000000')
self.check_balance(entity_a3.address, TMSC, '13.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv1, '88.00000000', '0.00000000')
self.check_balance(entity_a2.address, TDiv1, '45.00000000', '5.00000000')
self.check_balance(entity_a3.address, TDiv1, '12.00000000', '0.00000000')
# A77
entity_a3.trade('2.00000000', TMSC, '1.00000000', TDiv1)
self.generate_block()
#
#
# A2: SELL 5.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 5.00000000 TMSC)
#
# A3; BUY 1.00000000 TDiv1 @ 2.00000000 TMSC/TDiv1 (total: 2.00000000 TMSC) << pending
#
# ^ TODO: "BUY" looks strange in this context, because in fact 2.0 TMSC are offered.
# =>
#
# A3 BUYS 2.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 2.00000000 TMSC)
#
# =>
#
# A2: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC) << updated
#
#
# Movements:
# A3->A2: 2.00000000 TMSC, A2->A3: 2.00000000 TDiv1
#
self.check_balance(entity_a2.address, TMSC, '52.00000000', '0.00000000')
self.check_balance(entity_a3.address, TMSC, '11.00000000', '0.00000000')
self.check_balance(entity_a2.address, TDiv1, '45.00000000', '3.00000000')
self.check_balance(entity_a3.address, TDiv1, '14.00000000', '0.00000000')
# A78
entity_a3.trade('0.00000002', TMSC, '0.00000001', TDiv1)
self.generate_block()
#
#
# A2: SELL 3.00000000 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 3.00000000 TMSC)
#
# A3: BUY 0.00000001 TDiv1 @ 2.00000000 TMSC/TDiv1 (total: 0.00000002 TMSC) << pending
#
# =>
#
# A3 BUYS 0.00000002 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 0.00000002 TMSC)
#
# =>
#
# A2: SELL 2.99999998 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 2.99999998 TMSC) << updated
#
#
# Movements:
# A3->A2: 0.00000002 TMSC, A2->A3: 0.00000002 TDiv1
#
self.check_balance(entity_a2.address, TMSC, '52.00000002', '0.00000000')
self.check_balance(entity_a3.address, TMSC, '10.99999998', '0.00000000')
self.check_balance(entity_a2.address, TDiv1, '45.00000000', '2.99999998')
self.check_balance(entity_a3.address, TDiv1, '14.00000002', '0.00000000')
# A79
entity_a3.trade('5.00000000', TMSC, '4.00000000', TDiv1)
self.generate_block()
#
#
# A2: SELL 2.99999998 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 2.99999998 TMSC)
#
# A3: BUY 4.00000000 TDiv1 @ 1.25000000 TMSC/TDiv1 (total: 5.00000000 TMSC) << pending
#
# =>
#
# A3 BUYS 2.99999998 TDiv1 @ 1.00000000 TMSC/TDiv1 (total: 2.99999998 TMSC)
#
# =>
#
# A3: BUY 1.600000016 TDiv1 @ 1.25000000 TMSC/TDiv1 (total: 2.00000002 TMSC) << added
#
#
# Movements:
# A3->A2: 2.99999998 TMSC, A2->A3: 2.99999998 TDiv1
#
self.check_balance(entity_a2.address, TMSC, '55.00000000', '0.00000000')
self.check_balance(entity_a3.address, TMSC, '5.99999998', '2.00000002')
self.check_balance(entity_a2.address, TDiv1, '45.00000000', '0.00000000')
self.check_balance(entity_a3.address, TDiv1, '17.00000000', '0.00000000')
# A78
entity_a3.trade('5.00000000', TMSC, '4.00000000', TDiv1, CANCEL_2)
self.generate_block()
#
#
# A3: BUY 1.600000016 TDiv1 @ 1.25000000 TMSC/TDiv1 (total: 2.00000002 TMSC)
#
# A3: CANCEL 4.00000000 TDiv1 @ 1.25000000 TMSC/TDiv1 (total: 5.00000000 TMSC) << pending
#
# =>
#
# No more open orders for TDiv1 / TMSC
#
#
self.check_balance(entity_a3.address, TMSC, '8.00000000', '0.00000000')
self.check_balance(entity_a3.address, TDiv1, '17.00000000', '0.00000000')
# 83-90
def test_match_divisible_with_three(self):
"""Tests matching and execution of orders with more than one match.
Tests also invalidation of CANCEL-PAIR commands where no matching, open orders exists."""
entity_a1 = self.entities[1]
entity_a2 = self.entities[2]
entity_a3 = self.entities[3]
#
# Orderbook:
#
# A1: SELL 5 TIndiv1 @ 1.20000000 TMSC/TIndiv1 (total: 6.0 TMSC)
#
#
self.check_balance(entity_a1.address, TMSC, '162.00000000', '0.00000000')
self.check_balance(entity_a2.address, TMSC, '55.00000000', '0.00000000')
self.check_balance(entity_a3.address, TMSC, '8.00000000', '0.00000000')
self.check_balance(entity_a1.address, TDiv3, '0.00000000', '0.00000000')
self.check_balance(entity_a2.address, TDiv3, '200.00000000', '0.00000000')
self.check_balance(entity_a3.address, TDiv3, '200.00000000', '0.00000000')
# NOTE: Negative amounts are currently parsed as 0 by StrToInt64, but it should not matter in this context.
TestInfo.ExpectFail()
# A83 (amounts should be ignored in CANCEL-PAIR operations)
try: txid_a83 = entity_a2.trade('-0.00000001', TDiv3, '0.00000000', TMSC, CANCEL_3)
except: txid_a83 = '0'
self.check_invalid('A2 does not have any open order of pair TDiv3 - TMSC', txid_a83)
# A84 (amounts should be ignored in CANCEL-PAIR operations)
try: txid_a84 = entity_a3.trade('0.00000000', TDiv3, '-0.00000001', TMSC, CANCEL_3)
except: txid_a84 = '0'
self.check_invalid('A3 does not have any open order of pair TDiv3 - TMSC', txid_a84)
# A85 with zero amounts (amounts should be ignored in CANCEL-PAIR operations)
try: txid_a85_a = entity_a1.trade('0.00000000', TMSC, '0.00000000', TDiv3, CANCEL_3)
except: txid_a85_a = '0'
self.check_invalid('A1 does not have any open order of pair TMSC - TDiv3', txid_a85_a)
# A85 with positive amounts (amounts should be ignored in CANCEL-PAIR operations)
try: txid_a85_b = entity_a1.trade('6.00000000', TMSC, '0.00000005', TDiv3, CANCEL_3)
except: txid_a85_b = '0'
self.check_invalid('A1 does not have any open order of pair TMSC - TDiv3', txid_a85_b)
TestInfo.StopExpectation()
# A86
entity_a2.trade('10.00000000', TDiv3, '5.00000000', TMSC)
self.generate_block()
#
#
# A2: SELL 10.00000000 TDiv3 @ 0.50000000 TMSC/TDiv3 (total: 5.0 TMSC) << added
#
#
self.check_balance(entity_a2.address, TMSC, '55.00000000', '0.00000000')
self.check_balance(entity_a2.address, TDiv3, '190.00000000', '10.00000000')
# A87
entity_a3.trade('10.00000000', TDiv3, '10.00000000', TMSC)
self.generate_block()
#
#
# A3: SELL 10.00000000 TDiv3 @ 1.00000000 TMSC/TDiv3 (total: 10.0 TMSC) << added
# A2: SELL 10.00000000 TDiv3 @ 0.50000000 TMSC/TDiv3 (total: 5.0 TMSC)
#
#
self.check_balance(entity_a3.address, TMSC, '8.00000000', '0.00000000')
self.check_balance(entity_a3.address, TDiv3, '190.00000000', '10.00000000')
# A88
entity_a2.trade('15.00000000', TDiv3, '22.50000000', TMSC)
self.generate_block()
#
#
# A2: SELL 15.00000000 TDiv3 @ 1.50000000 TMSC/TDiv3 (total: 22.5 TMSC) << added
# A3: SELL 10.00000000 TDiv3 @ 1.00000000 TMSC/TDiv3 (total: 10.0 TMSC)
# A2: SELL 10.00000000 TDiv3 @ 0.50000000 TMSC/TDiv3 (total: 5.0 TMSC)
#
#
self.check_balance(entity_a2.address, TMSC, '55.00000000', '0.00000000')
self.check_balance(entity_a2.address, TDiv3, '175.00000000', '25.00000000')
# A89
entity_a1.trade('60.00000000', TMSC, '120.00000001', TDiv3)
self.generate_block()
#
#
# A2: SELL 15.00000000 TDiv3 @ 1.50000000 TMSC/TDiv3 (total: 22.5 TMSC)
# A3: SELL 10.00000000 TDiv3 @ 1.00000000 TMSC/TDiv3 (total: 10.0 TMSC)
# A2: SELL 10.00000000 TDiv3 @ 0.50000000 TMSC/TDiv3 (total: 5.0 TMSC)
#
# A1: BUY 120.00000001 TDiv3 @ 0.49999999995833333333680555.. TMSC/TDiv3 (total: 60.0 TMSC) << added
#
#
self.check_balance(entity_a1.address, TMSC, '102.00000000', '60.00000000')
self.check_balance(entity_a1.address, TDiv3, '0.00000000', '0.00000000')
# A88
entity_a1.trade('45.00000000', TMSC, '22.50000000', TDiv3)
self.generate_block()
#
#
# A2: SELL 15.00000000 TDiv3 @ 1.50000000 TMSC/TDiv3 (total: 22.5 TMSC)
# A3: SELL 10.00000000 TDiv3 @ 1.00000000 TMSC/TDiv3 (total: 10.0 TMSC)
# A2: SELL 10.00000000 TDiv3 @ 0.50000000 TMSC/TDiv3 (total: 5.0 TMSC)
#
# A1: BUY 22.50000000 TDiv3 @ 2.00000000 TMSC/TDiv3 (total: 45.0 TMSC) << pending
# A1: BUY 120.00000001 TDiv3 @ 0.49999999 TMSC/TDiv3 (total: 60.0 TMSC)
#
# =>
#
# A1 BUYS 10.00000000 TDiv3 @ 0.50000000 TMSC/TDiv3 (total: 5.0 TMSC)
# A1 BUYS 10.00000000 TDiv3 @ 1.00000000 TMSC/TDiv3 (total: 10.0 TMSC)
# A1 BUYS 15.00000000 TDiv3 @ 1.50000000 TMSC/TDiv3 (total: 22.5 TMSC)
#
# =>
#
# A1: BUY 3.75000000 TDiv3 @ 2.00000000 TMSC/TDiv3 (total: 7.5 TMSC) << updated
# A1: BUY 120.00000001 TDiv3 @ 0.49999999 TMSC/TDiv3 (total: 60.0 TMSC)
#
#
# Movements:
# A1->A2: 5.0 TMSC, A2->A1: 10.0 TDiv3