Files
1641c3c852 feat: update for Ledger v2 (#468)
Co-authored-by: Antoine Wacheux <[email protected]>
Co-authored-by: Maxence Maireaux <[email protected]>
Co-authored-by: Brieuc Caillot <[email protected]>
2023-09-20 16:40:28 +02:00

67 lines
1.1 KiB
Go

package ledger
import (
"math/big"
"testing"
"github.com/stretchr/testify/require"
)
func TestReverseMultiple(t *testing.T) {
p := Postings{
{
Source: "world",
Destination: "users:001",
Amount: big.NewInt(100),
Asset: "COIN",
},
{
Source: "users:001",
Destination: "payments:001",
Amount: big.NewInt(100),
Asset: "COIN",
},
}
expected := Postings{
{
Source: "payments:001",
Destination: "users:001",
Amount: big.NewInt(100),
Asset: "COIN",
},
{
Source: "users:001",
Destination: "world",
Amount: big.NewInt(100),
Asset: "COIN",
},
}
p.Reverse()
require.Equal(t, expected, p)
}
func TestReverseSingle(t *testing.T) {
p := Postings{
{
Source: "world",
Destination: "users:001",
Amount: big.NewInt(100),
Asset: "COIN",
},
}
expected := Postings{
{
Source: "users:001",
Destination: "world",
Amount: big.NewInt(100),
Asset: "COIN",
},
}
p.Reverse()
require.Equal(t, expected, p)
}