go-waku/waku/v2/protocol/swap/waku_swap_test.go

22 lines
407 B
Go
Raw Normal View History

package swap
import (
"testing"
2022-05-06 19:29:31 +00:00
"github.com/status-im/go-waku/waku/v2/utils"
"github.com/stretchr/testify/require"
)
func TestSwapCreditDebit(t *testing.T) {
2022-05-27 13:25:06 +00:00
swap := NewWakuSwap(utils.Logger().Sugar(), []SwapOption{
WithMode(SoftMode),
WithThreshold(0, 0),
}...)
swap.Credit("1", 1)
require.Equal(t, -1, swap.Accounting["1"])
swap.Debit("1", 2)
require.Equal(t, 1, swap.Accounting["1"])
}