@@ -4568,3 +4568,98 @@ func TestInvalidColor(t *testing.T) {
45684568 }
45694569 testWithFeatureFlag (t , tc , flags .ExperimentalAssetColors )
45704570}
4571+
4572+ func TestThroughRemoveColor (t * testing.T ) {
4573+ script := `
4574+ send [USD 10] (
4575+ source = @src \ "BLUE" through @proxy
4576+ destination = @dest
4577+ )
4578+ `
4579+
4580+ tc := NewTestCase ()
4581+ tc .compile (t , script )
4582+
4583+ tc .setBalance ("src" , "USD_BLUE" , 999 )
4584+
4585+ tc .expected = CaseResult {
4586+ Postings : []Posting {
4587+ {
4588+ Asset : "USD_BLUE" ,
4589+ Amount : big .NewInt (10 ),
4590+ Source : "src" ,
4591+ Destination : "proxy" ,
4592+ },
4593+
4594+ {
4595+ Asset : "USD" ,
4596+ Amount : big .NewInt (10 ),
4597+ Source : "proxy" ,
4598+ Destination : "dest" ,
4599+ },
4600+ },
4601+ Error : nil ,
4602+ }
4603+ testWithFeatureFlag (t , tc , flags .ExperimentalAssetColors )
4604+ }
4605+
4606+ func TestThroughRecolor (t * testing.T ) {
4607+ script := `
4608+ send [USD 10] (
4609+ source = @src \ "BLUE" through @proxy\"RED"
4610+ destination = @dest
4611+ )
4612+ `
4613+
4614+ tc := NewTestCase ()
4615+ tc .compile (t , script )
4616+
4617+ tc .setBalance ("src" , "USD_BLUE" , 999 )
4618+ tc .setBalance ("proxy" , "USD_RED" , 999 )
4619+
4620+ tc .expected = CaseResult {
4621+ Postings : []Posting {
4622+ {
4623+ Asset : "USD_BLUE" ,
4624+ Amount : big .NewInt (10 ),
4625+ Source : "src" ,
4626+ Destination : "proxy" ,
4627+ },
4628+
4629+ {
4630+ Asset : "USD_RED" ,
4631+ Amount : big .NewInt (10 ),
4632+ Source : "proxy" ,
4633+ Destination : "dest" ,
4634+ },
4635+ },
4636+ Error : nil ,
4637+ }
4638+ testWithFeatureFlag (t , tc , flags .ExperimentalAssetColors )
4639+ }
4640+
4641+ func TestThroughNoBalanceForProxy (t * testing.T ) {
4642+ t .Skip ("TODO" )
4643+
4644+ script := `
4645+ send [USD 10] (
4646+ source = @world through @proxy\"RED"
4647+ destination = @dest
4648+ )
4649+ `
4650+
4651+ tc := NewTestCase ()
4652+ tc .compile (t , script )
4653+
4654+ tc .setBalance ("proxy" , "USD_RED" , 1 )
4655+
4656+ tc .expected = CaseResult {
4657+ Postings : []Posting {},
4658+ Error : machine.MissingFundsErr {
4659+ Asset : "USD" ,
4660+ Needed : * big .NewInt (10 ),
4661+ Available : * big .NewInt (0 ),
4662+ },
4663+ }
4664+ testWithFeatureFlag (t , tc , flags .ExperimentalAssetColors )
4665+ }
0 commit comments