Skip to content

Commit 02e1423

Browse files
authored
tests: add tests (#68)
1 parent 9a3892d commit 02e1423

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

internal/interpreter/interpreter_test.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4406,6 +4406,79 @@ func TestColorInorderSendAll(t *testing.T) {
44064406
testWithFeatureFlag(t, tc, flags.ExperimentalAssetColors)
44074407
}
44084408

4409+
func TestNoDoubleSpendingInColoredSendAll(t *testing.T) {
4410+
4411+
script := `
4412+
send [COIN *] (
4413+
source = {
4414+
@src \ "X"
4415+
@src \ "X"
4416+
@src
4417+
}
4418+
destination = @dest
4419+
)
4420+
`
4421+
4422+
tc := NewTestCase()
4423+
tc.setBalance("src", "COIN", 100)
4424+
tc.setBalance("src", "COIN_X", 20)
4425+
tc.compile(t, script)
4426+
4427+
tc.expected = CaseResult{
4428+
Postings: []Posting{
4429+
{
4430+
Asset: "COIN_X",
4431+
Amount: big.NewInt(20),
4432+
Source: "src",
4433+
Destination: "dest",
4434+
},
4435+
{
4436+
Asset: "COIN",
4437+
Amount: big.NewInt(100),
4438+
Source: "src",
4439+
Destination: "dest",
4440+
},
4441+
},
4442+
}
4443+
testWithFeatureFlag(t, tc, flags.ExperimentalAssetColors)
4444+
}
4445+
4446+
func TestNoDoubleSpendingInColoredSend(t *testing.T) {
4447+
script := `
4448+
send [COIN 100] (
4449+
source = {
4450+
@src \ "X"
4451+
@src \ "X"
4452+
@src
4453+
}
4454+
destination = @dest
4455+
)
4456+
`
4457+
4458+
tc := NewTestCase()
4459+
tc.setBalance("src", "COIN", 99999)
4460+
tc.setBalance("src", "COIN_X", 20)
4461+
tc.compile(t, script)
4462+
4463+
tc.expected = CaseResult{
4464+
Postings: []Posting{
4465+
{
4466+
Asset: "COIN_X",
4467+
Amount: big.NewInt(20),
4468+
Source: "src",
4469+
Destination: "dest",
4470+
},
4471+
{
4472+
Asset: "COIN",
4473+
Amount: big.NewInt(80),
4474+
Source: "src",
4475+
Destination: "dest",
4476+
},
4477+
},
4478+
}
4479+
testWithFeatureFlag(t, tc, flags.ExperimentalAssetColors)
4480+
}
4481+
44094482
func TestEmptyColor(t *testing.T) {
44104483
// empty string color behaves as no color
44114484

0 commit comments

Comments
 (0)