File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -5528,3 +5528,68 @@ send [USD/2 10] (
5528
5528
})
5529
5529
5530
5530
}
5531
+
5532
+ func TestSendHalfUsingVirtual (t * testing.T ) {
5533
+ script := `
5534
+ vars { account $v = virtual() }
5535
+
5536
+ send [USD/2 10] (
5537
+ source = {
5538
+ 1/2 from @alice
5539
+ remaining from $v allowing unbounded overdraft
5540
+ }
5541
+ destination = @interests
5542
+ )
5543
+ `
5544
+
5545
+ tc := NewTestCase ()
5546
+ tc .compile (t , script )
5547
+ tc .setBalance ("alice" , "USD/2" , 5 )
5548
+
5549
+ tc .expected = CaseResult {
5550
+ Postings : []machine.Posting {
5551
+ {
5552
+ Source : "alice" ,
5553
+ Destination : "interests" ,
5554
+ Asset : "USD/2" ,
5555
+ Amount : big .NewInt (5 ),
5556
+ },
5557
+ },
5558
+ }
5559
+ test (t , tc )
5560
+ }
5561
+
5562
+ func TestVirtualSendCreditAround (t * testing.T ) {
5563
+ script := `
5564
+ vars {
5565
+ account $v1 = virtual()
5566
+ account $v2 = virtual()
5567
+ }
5568
+
5569
+ send [USD 1] (
5570
+ source = $v1 allowing unbounded overdraft
5571
+ destination = $v2
5572
+ )
5573
+
5574
+ send [USD 1] (
5575
+ // here's we're sending the credit we have from $v1
5576
+ // so $v2 doesn't "owe" anything to @dest
5577
+ source = $v2
5578
+ destination = @dest
5579
+ )
5580
+
5581
+ send [USD 1] (
5582
+ // that's why this doesn't output any postings
5583
+ source = @world
5584
+ destination = $v2
5585
+ )
5586
+ `
5587
+
5588
+ tc := NewTestCase ()
5589
+ tc .compile (t , script )
5590
+
5591
+ tc .expected = CaseResult {
5592
+ Postings : []machine.Posting {},
5593
+ }
5594
+ test (t , tc )
5595
+ }
You can’t perform that action at this time.
0 commit comments