Annotate paych tests
This commit is contained in:
parent
a64f2421d2
commit
0f83a0a634
@ -44,6 +44,9 @@ func TestCheckVoucherValid(t *testing.T) {
|
||||
mock.setAccountAddress(fromAcct, from)
|
||||
mock.setAccountAddress(toAcct, to)
|
||||
|
||||
//stm: @TOKEN_PAYCH_VOUCHER_VALID_001, @TOKEN_PAYCH_VOUCHER_VALID_002, @TOKEN_PAYCH_VOUCHER_VALID_003
|
||||
//stm: @TOKEN_PAYCH_VOUCHER_VALID_004, @TOKEN_PAYCH_VOUCHER_VALID_005, @TOKEN_PAYCH_VOUCHER_VALID_006, @TOKEN_PAYCH_VOUCHER_VALID_007
|
||||
//stm: @TOKEN_PAYCH_VOUCHER_VALID_009, @TOKEN_PAYCH_VOUCHER_VALID_010
|
||||
tcases := []struct {
|
||||
name string
|
||||
expectError bool
|
||||
@ -243,6 +246,7 @@ func TestCreateVoucher(t *testing.T) {
|
||||
Lane: 1,
|
||||
Amount: voucherLane1Amt,
|
||||
}
|
||||
//stm: @TOKEN_PAYCH_VOUCHER_CREATE_001
|
||||
res, err := s.mgr.CreateVoucher(ctx, s.ch, voucher)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, res.Voucher)
|
||||
@ -287,6 +291,7 @@ func TestCreateVoucher(t *testing.T) {
|
||||
Lane: 2,
|
||||
Amount: voucherLane2Amt,
|
||||
}
|
||||
//stm: @TOKEN_PAYCH_VOUCHER_CREATE_004
|
||||
res, err = s.mgr.CreateVoucher(ctx, s.ch, voucher)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -297,6 +302,7 @@ func TestCreateVoucher(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddVoucherDelta(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_LIST_VOUCHERS_001
|
||||
ctx := context.Background()
|
||||
|
||||
// Set up a manager with a single payment channel
|
||||
@ -358,6 +364,7 @@ func TestAddVoucherNextLane(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, ci.NextLane, 3)
|
||||
|
||||
//stm: @TOKEN_PAYCH_ALLOCATE_LANE_001
|
||||
// Allocate a lane (should be lane 3)
|
||||
lane, err := s.mgr.AllocateLane(s.ch)
|
||||
require.NoError(t, err)
|
||||
@ -392,6 +399,7 @@ func TestAllocateLane(t *testing.T) {
|
||||
// Set up a manager with a single payment channel
|
||||
s := testSetupMgrWithChannel(t)
|
||||
|
||||
//stm: @TOKEN_PAYCH_ALLOCATE_LANE_001
|
||||
// First lane should be 0
|
||||
lane, err := s.mgr.AllocateLane(s.ch)
|
||||
require.NoError(t, err)
|
||||
@ -446,6 +454,7 @@ func TestAllocateLaneWithExistingLaneState(t *testing.T) {
|
||||
_, err = mgr.AddVoucherInbound(ctx, ch, sv, nil, minDelta)
|
||||
require.NoError(t, err)
|
||||
|
||||
//stm: @TOKEN_PAYCH_ALLOCATE_LANE_001
|
||||
// Allocate lane should return the next lane (lane 3)
|
||||
lane, err := mgr.AllocateLane(ch)
|
||||
require.NoError(t, err)
|
||||
@ -508,6 +517,7 @@ func TestAddVoucherInboundWalletKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBestSpendable(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_LIST_VOUCHERS_001
|
||||
ctx := context.Background()
|
||||
|
||||
// Set up a manager with a single payment channel
|
||||
@ -550,6 +560,7 @@ func TestBestSpendable(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
//stm: @TOKEN_PAYCH_BEST_SPENDABLE_001
|
||||
// Verify best spendable vouchers on each lane
|
||||
vouchers, err := BestSpendableByLane(ctx, bsapi, s.ch)
|
||||
require.NoError(t, err)
|
||||
@ -690,6 +701,7 @@ func TestSubmitVoucher(t *testing.T) {
|
||||
err = p3.UnmarshalCBOR(bytes.NewReader(msg.Message.Params))
|
||||
require.NoError(t, err)
|
||||
|
||||
//stm: @TOKEN_PAYCH_LIST_VOUCHERS_001
|
||||
// Verify that vouchers are marked as submitted
|
||||
vis, err := s.mgr.ListVouchers(ctx, s.ch)
|
||||
require.NoError(t, err)
|
||||
|
@ -68,6 +68,7 @@ func TestPaychGetCreateChannelMsg(t *testing.T) {
|
||||
// TestPaychGetCreateChannelThenAddFunds tests creating a channel and then
|
||||
// adding funds to it
|
||||
func TestPaychGetCreateChannelThenAddFunds(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_LIST_CHANNELS_001, @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
@ -158,6 +159,7 @@ func TestPaychGetCreateChannelThenAddFunds(t *testing.T) {
|
||||
// operation is queued up behind a create channel operation, and the create
|
||||
// channel fails, then the waiting operation can succeed.
|
||||
func TestPaychGetCreateChannelWithErrorThenCreateAgain(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_LIST_CHANNELS_001, @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
@ -222,6 +224,7 @@ func TestPaychGetCreateChannelWithErrorThenCreateAgain(t *testing.T) {
|
||||
// TestPaychGetRecoverAfterError tests that after a create channel fails, the
|
||||
// next attempt to create channel can succeed.
|
||||
func TestPaychGetRecoverAfterError(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_LIST_CHANNELS_001, @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
@ -274,6 +277,7 @@ func TestPaychGetRecoverAfterError(t *testing.T) {
|
||||
// TestPaychGetRecoverAfterAddFundsError tests that after an add funds fails, the
|
||||
// next attempt to add funds can succeed.
|
||||
func TestPaychGetRecoverAfterAddFundsError(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_LIST_CHANNELS_001, @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
@ -356,6 +360,7 @@ func TestPaychGetRecoverAfterAddFundsError(t *testing.T) {
|
||||
// right after the create channel message is sent, the channel will be
|
||||
// created when the system restarts.
|
||||
func TestPaychGetRestartAfterCreateChannelMsg(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_LIST_CHANNELS_001, @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
@ -435,6 +440,7 @@ func TestPaychGetRestartAfterCreateChannelMsg(t *testing.T) {
|
||||
// right after the add funds message is sent, the add funds will be
|
||||
// processed when the system restarts.
|
||||
func TestPaychGetRestartAfterAddFundsMsg(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_LIST_CHANNELS_001, @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
@ -498,6 +504,7 @@ func TestPaychGetRestartAfterAddFundsMsg(t *testing.T) {
|
||||
// TestPaychGetWait tests that GetPaychWaitReady correctly waits for the
|
||||
// channel to be created or funds to be added
|
||||
func TestPaychGetWait(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
@ -555,6 +562,7 @@ func TestPaychGetWait(t *testing.T) {
|
||||
|
||||
// TestPaychGetWaitErr tests that GetPaychWaitReady correctly handles errors
|
||||
func TestPaychGetWaitErr(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
@ -602,6 +610,7 @@ func TestPaychGetWaitErr(t *testing.T) {
|
||||
// TestPaychGetWaitCtx tests that GetPaychWaitReady returns early if the context
|
||||
// is cancelled
|
||||
func TestPaychGetWaitCtx(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
@ -631,6 +640,7 @@ func TestPaychGetWaitCtx(t *testing.T) {
|
||||
// progress and two add funds are queued up behind it, the two add funds
|
||||
// will be merged
|
||||
func TestPaychGetMergeAddFunds(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
@ -729,6 +739,7 @@ func TestPaychGetMergeAddFunds(t *testing.T) {
|
||||
// TestPaychGetMergeAddFundsCtxCancelOne tests that when a queued add funds
|
||||
// request is cancelled, its amount is removed from the total merged add funds
|
||||
func TestPaychGetMergeAddFundsCtxCancelOne(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
@ -826,6 +837,7 @@ func TestPaychGetMergeAddFundsCtxCancelOne(t *testing.T) {
|
||||
// TestPaychGetMergeAddFundsCtxCancelAll tests that when all queued add funds
|
||||
// requests are cancelled, no add funds message is sent
|
||||
func TestPaychGetMergeAddFundsCtxCancelAll(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
@ -900,6 +912,7 @@ func TestPaychGetMergeAddFundsCtxCancelAll(t *testing.T) {
|
||||
// TestPaychAvailableFunds tests that PaychAvailableFunds returns the correct
|
||||
// channel state
|
||||
func TestPaychAvailableFunds(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_WAIT_READY_001, @TOKEN_PAYCH_AVAILABLE_FUNDS_001, @TOKEN_PAYCH_AVAILABLE_FUNDS_002, @TOKEN_PAYCH_AVAILABLE_FUNDS_003
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
// insufficient funds, then adding funds to the channel, then adding the
|
||||
// voucher again
|
||||
func TestPaychAddVoucherAfterAddFunds(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_WAIT_READY_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPaychSettle(t *testing.T) {
|
||||
//stm: @TOKEN_PAYCH_WAIT_READY_001, @TOKEN_PAYCH_SETTLE_001, @TOKEN_PAYCH_LIST_CHANNELS_001
|
||||
ctx := context.Background()
|
||||
store := NewStore(ds_sync.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user