You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: reverifyqueue_test.go
    path of file: ./repos/storj/satellite/satellitedb
    
    the code of the file until where you have to start completion: // Copyright (C) 2022 Storj Labs, Inc.
// See LICENSE for copying information.

package satellitedb_test

import (
	"context"
	"sort"
	"testing"
	"time"

	"github.com/stretchr/testify/require"

	"storj.io/common/storj"
	"storj.io/common/sync2"
	"storj.io/common/testcontext"
	"storj.io/common/testrand"
	"storj.io/storj/satellite"
	"storj.io/storj/satellite/audit"
	"storj.io/storj/satellite/metabase"
	"storj.io/storj/satellite/satellitedb/satellitedbtest"
)

func randomLocator() *audit.PieceLocator {
	return &audit.PieceLocator{
		StreamID: testrand.UUID(),
		Position: metabase.SegmentPosition{
			Part:  uint32(testrand.Intn(1 << 10)),
			Index: uint32(testrand.Intn(1 << 20)),
		},
		NodeID:   testrand.NodeID(),
		PieceNum: testrand.Intn(1 << 10),
	}
}

const (
	retryInterval = 30 * time.Minute
)

func TestReverifyQueue(t *testing.T) {
	satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
		reverifyQueue := db.ReverifyQueue()
		reverifyQueueTest := reverifyQueue.(interface {
			TestingFudgeUpdateTime(ctx context.Context, piece *audit.PieceLocator, updateTime time.Time) error
		})

		locator1 := randomLocator()
		locator2 := randomLocator()

		err := reverifyQueue.Insert(ctx, locator1)
		require.NoError(t, err)

		// Postgres/Cockroach have only microsecond time resolution, so make
		// sure at least 1us has elapsed before inserting the second.
		sync2.Sleep(ctx, time.Microsecond)

		err = reverifyQueue.Insert(ctx, locator2)
		require.NoError(t, err)

		checkGetAllContainedNodes(ctx, t, reverifyQueue, locator1.NodeID, lo
    
func TestReverifyQueueGetByNodeID(t *testing.T) {
	satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
		reverifyQueue := db.ReverifyQueue()

		locator1 := randomLocator()
		locator2 := randomLocator()
		locator3 := randomLocator()
		// two jobs on the same node
		locator3.NodeID = locator1.NodeID

		err := reverifyQueue.Insert(ctx, locator1)
		require.NoError(t, err)

		// Postgres/Cockroach have only microsecond time resolution, so make
		// sure at least 1us has elapsed between inserts.
		sync2.Sleep(ctx, time.Microsecond)

		err = reverifyQueue.Insert(ctx, locator2)
		require.NoError(t, err)

		sync2.Sleep(ctx, time.Microsecond)

		err = reverifyQueue.Insert(ctx, locator3)
		require.NoError(t, err)

		job1, err := reverifyQueue.GetByNodeID(ctx, locator1.NodeID)
		require.NoError(t, err)

		// we got either locator1 or locator3
		if job1.Locator.StreamID == locator1.StreamID {
			require.Equal(t, locator1.NodeID, job1.Locator.NodeID)
			require.Equal(t, locator1.PieceNum, job1.Locator.PieceNum)
			require.Equal(t, locator1.Position, job1.Locator.Position)
		} else {
			require.Equal(t, locator3.StreamID, job1.Locator.StreamID)
			require.Equal(t, locator3.NodeID, job1.Locator.NodeID)
			require.Equal(t, locator3.PieceNum, job1.Locator.PieceNum)
			require.Equal(t, locator3.Position, job1.Locator.Position)
		}

		job2, err := reverifyQueue.GetByNodeID(ctx, locator2.NodeID)
		require.NoError(t, err)
		require.Equal(t, locator2.StreamID, job2.Locator.StreamID)
		require.Equal(t, locator2.NodeID, job2.Locator.NodeID)
		require.Equal(t, locator2.PieceNum, job2.Locator.PieceNum)
		require.Equal(t, locator2.Position, job2.Locator.Position)

		// ask for a nonexistent node ID
		job3, err := reverifyQueue.GetByNodeID(ctx, testrand.NodeID())
		require.Error(t, err)
		require.Truef(t, audit.ErrContainedNotFound.Has(err), "expected ErrContainedNotFound error but got %+v", err)
		require.Nil(t, job3)
	})
}