dee2c137c8
* slowly but surely * hardcode ID for tests so we can get predictable results * skipping bad test * removing tests of bkad * wip * new algorithm for worker * clean up * remove skipped test * changes * uncomment * fixed conflicts * maybe done ? * cleanup * boot bkad * wip * cleanup * undo change * fixes * wip * wip * moving nodeID around * wip * wip * fixes * fixes after merge * added TODO * fixed tests post identity * linter fixes * wip * PR review comments * wip * fixing tests * fix tests * force db directory * bad test * fixes race condition * small cleanups * adding db folder * testing * wip * cleanup * cleanup * linters * export Restrict * add timeout * testing * linters * forgot one * moar fixes from master merge * PR comments * moar PR comments * removed stun flag * remove duplicate declaration * remove old tests * remove timeout * fix tests * missed one * changed StringToID >> IDFromString * PR comments * stupid linter * moevd overlay mock * fixed merge conflicts * fixes * linter
43 lines
916 B
Go
43 lines
916 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package client
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mr-tron/base58/base58"
|
|
"github.com/stretchr/testify/assert"
|
|
"storj.io/storj/pkg/node"
|
|
)
|
|
|
|
func TestNewPieceID(t *testing.T) {
|
|
t.Run("should return an id string", func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
id := NewPieceID()
|
|
assert.Equal(id.IsValid(), true)
|
|
})
|
|
|
|
t.Run("should return a different string on each call", func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
assert.NotEqual(NewPieceID(), NewPieceID())
|
|
})
|
|
}
|
|
|
|
func TestDerivePieceID(t *testing.T) {
|
|
pid := NewPieceID()
|
|
nid, err := node.NewID()
|
|
assert.NoError(t, err)
|
|
|
|
did, err := pid.Derive(nid.Bytes())
|
|
assert.NoError(t, err)
|
|
assert.NotEqual(t, pid, did)
|
|
|
|
did2, err := pid.Derive(nid.Bytes())
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, did, did2)
|
|
|
|
_, err = base58.Decode(did.String())
|
|
assert.NoError(t, err)
|
|
}
|