storj/storagenode/storagenodedb/vouchers_test.go
Cameron 5f096a3eab
Remove GetValid, add GetAll to vouchers DB (#2594)
* refactor GetValid to GetAll

* update design doc
2019-07-19 10:52:44 -04:00

40 lines
808 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package storagenodedb
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/require"
"storj.io/storj/internal/testrand"
"storj.io/storj/pkg/pb"
)
func TestVouchers_Trivial(t *testing.T) {
Run(t, func(t *testing.T, ctx context.Context, db *DB) {
satelliteID := testrand.NodeID()
{ // Ensure Put works at all
err := db.Vouchers().Put(ctx, &pb.Voucher{
SatelliteId: satelliteID,
Expiration: time.Now(),
})
require.NoError(t, err)
}
{ // Ensure NeedVoucher works at all
_, err := db.Vouchers().NeedVoucher(ctx, satelliteID, time.Hour)
require.NoError(t, err)
}
{ // Ensure GetValid works at all
_, err := db.Vouchers().GetAll(ctx)
require.NoError(t, err)
}
})
}