storj/storagenode/storagenodedb/vouchers_test.go

41 lines
867 B
Go
Raw Normal View History

// 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"
"storj.io/storj/pkg/storj"
)
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().GetValid(ctx, []storj.NodeID{satelliteID})
require.NoError(t, err)
}
})
}