fix non-deterministic ordering in unit tests #268
@ -687,8 +687,12 @@ func testPublishAndIndexStorageIPLDs(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
require.Equal(t, 3, len(storageNodes))
|
require.Equal(t, 3, len(storageNodes))
|
||||||
expectedStorageNodes := []models.StorageNodeWithStateKeyModel{
|
gotStorageNodes := make(map[string]models.StorageNodeWithStateKeyModel, 3)
|
||||||
{
|
for _, model := range storageNodes {
|
||||||
|
gotStorageNodes[model.StorageKey] = model
|
||||||
|
}
|
||||||
|
expectedStorageNodes := map[string]models.StorageNodeWithStateKeyModel{
|
||||||
|
common.BytesToHash(mocks.RemovedLeafKey).Hex(): {
|
||||||
BlockNumber: mocks.BlockNumber.String(),
|
BlockNumber: mocks.BlockNumber.String(),
|
||||||
CID: shared.RemovedNodeStorageCID,
|
CID: shared.RemovedNodeStorageCID,
|
||||||
NodeType: 3,
|
NodeType: 3,
|
||||||
@ -696,7 +700,7 @@ func testPublishAndIndexStorageIPLDs(t *testing.T) {
|
|||||||
StateKey: common.BytesToHash(mocks.ContractLeafKey).Hex(),
|
StateKey: common.BytesToHash(mocks.ContractLeafKey).Hex(),
|
||||||
Path: []byte{'\x03'},
|
Path: []byte{'\x03'},
|
||||||
},
|
},
|
||||||
{
|
common.BytesToHash(mocks.Storage2LeafKey).Hex(): {
|
||||||
BlockNumber: mocks.BlockNumber.String(),
|
BlockNumber: mocks.BlockNumber.String(),
|
||||||
CID: shared.RemovedNodeStorageCID,
|
CID: shared.RemovedNodeStorageCID,
|
||||||
NodeType: 3,
|
NodeType: 3,
|
||||||
@ -704,7 +708,7 @@ func testPublishAndIndexStorageIPLDs(t *testing.T) {
|
|||||||
StateKey: common.BytesToHash(mocks.Contract2LeafKey).Hex(),
|
StateKey: common.BytesToHash(mocks.Contract2LeafKey).Hex(),
|
||||||
Path: []byte{'\x0e'},
|
Path: []byte{'\x0e'},
|
||||||
},
|
},
|
||||||
{
|
common.BytesToHash(mocks.Storage3LeafKey).Hex(): {
|
||||||
BlockNumber: mocks.BlockNumber.String(),
|
BlockNumber: mocks.BlockNumber.String(),
|
||||||
CID: shared.RemovedNodeStorageCID,
|
CID: shared.RemovedNodeStorageCID,
|
||||||
NodeType: 3,
|
NodeType: 3,
|
||||||
@ -713,15 +717,15 @@ func testPublishAndIndexStorageIPLDs(t *testing.T) {
|
|||||||
Path: []byte{'\x0f'},
|
Path: []byte{'\x0f'},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for idx, storageNode := range storageNodes {
|
for storageKey, storageNode := range gotStorageNodes {
|
||||||
require.Equal(t, expectedStorageNodes[idx], storageNode)
|
require.Equal(t, expectedStorageNodes[storageKey], storageNode)
|
||||||
dc, err = cid.Decode(storageNode.CID)
|
dc, err = cid.Decode(storageNode.CID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
mhKey = dshelp.MultihashToDsKey(dc.Hash())
|
mhKey = dshelp.MultihashToDsKey(dc.Hash())
|
||||||
prefixedKey = blockstore.BlockPrefix.String() + mhKey.String()
|
prefixedKey = blockstore.BlockPrefix.String() + mhKey.String()
|
||||||
require.Equal(t, shared.RemovedNodeMhKey, prefixedKey, mocks.BlockNumber.Uint64())
|
require.Equal(t, shared.RemovedNodeMhKey, prefixedKey)
|
||||||
err = sqlxdb.Get(&data, ipfsPgGet, prefixedKey, mocks.BlockNumber.Uint64())
|
err = sqlxdb.Get(&data, ipfsPgGet, prefixedKey, mocks.BlockNumber.Uint64())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -548,8 +548,12 @@ func TestPGXIndexer(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
require.Equal(t, 3, len(storageNodes))
|
require.Equal(t, 3, len(storageNodes))
|
||||||
expectedStorageNodes := []models.StorageNodeWithStateKeyModel{
|
gotStorageNodes := make(map[string]models.StorageNodeWithStateKeyModel, 3)
|
||||||
{
|
for _, model := range storageNodes {
|
||||||
|
gotStorageNodes[model.StorageKey] = model
|
||||||
|
}
|
||||||
|
expectedStorageNodes := map[string]models.StorageNodeWithStateKeyModel{
|
||||||
|
common.BytesToHash(mocks.RemovedLeafKey).Hex(): {
|
||||||
BlockNumber: mocks.BlockNumber.String(),
|
BlockNumber: mocks.BlockNumber.String(),
|
||||||
CID: shared.RemovedNodeStorageCID,
|
CID: shared.RemovedNodeStorageCID,
|
||||||
NodeType: 3,
|
NodeType: 3,
|
||||||
@ -557,7 +561,7 @@ func TestPGXIndexer(t *testing.T) {
|
|||||||
StateKey: common.BytesToHash(mocks.ContractLeafKey).Hex(),
|
StateKey: common.BytesToHash(mocks.ContractLeafKey).Hex(),
|
||||||
Path: []byte{'\x03'},
|
Path: []byte{'\x03'},
|
||||||
},
|
},
|
||||||
{
|
common.BytesToHash(mocks.Storage2LeafKey).Hex(): {
|
||||||
BlockNumber: mocks.BlockNumber.String(),
|
BlockNumber: mocks.BlockNumber.String(),
|
||||||
CID: shared.RemovedNodeStorageCID,
|
CID: shared.RemovedNodeStorageCID,
|
||||||
NodeType: 3,
|
NodeType: 3,
|
||||||
@ -565,7 +569,7 @@ func TestPGXIndexer(t *testing.T) {
|
|||||||
StateKey: common.BytesToHash(mocks.Contract2LeafKey).Hex(),
|
StateKey: common.BytesToHash(mocks.Contract2LeafKey).Hex(),
|
||||||
Path: []byte{'\x0e'},
|
Path: []byte{'\x0e'},
|
||||||
},
|
},
|
||||||
{
|
common.BytesToHash(mocks.Storage3LeafKey).Hex(): {
|
||||||
BlockNumber: mocks.BlockNumber.String(),
|
BlockNumber: mocks.BlockNumber.String(),
|
||||||
CID: shared.RemovedNodeStorageCID,
|
CID: shared.RemovedNodeStorageCID,
|
||||||
NodeType: 3,
|
NodeType: 3,
|
||||||
@ -574,8 +578,8 @@ func TestPGXIndexer(t *testing.T) {
|
|||||||
Path: []byte{'\x0f'},
|
Path: []byte{'\x0f'},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for idx, storageNode := range storageNodes {
|
for storageKey, storageNode := range gotStorageNodes {
|
||||||
require.Equal(t, expectedStorageNodes[idx], storageNode)
|
require.Equal(t, expectedStorageNodes[storageKey], storageNode)
|
||||||
dc, err = cid.Decode(storageNode.CID)
|
dc, err = cid.Decode(storageNode.CID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -541,8 +541,12 @@ func TestSQLXIndexer(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
require.Equal(t, 3, len(storageNodes))
|
require.Equal(t, 3, len(storageNodes))
|
||||||
expectedStorageNodes := []models.StorageNodeWithStateKeyModel{
|
gotStorageNodes := make(map[string]models.StorageNodeWithStateKeyModel, 3)
|
||||||
{
|
for _, model := range storageNodes {
|
||||||
|
gotStorageNodes[model.StorageKey] = model
|
||||||
|
}
|
||||||
|
expectedStorageNodes := map[string]models.StorageNodeWithStateKeyModel{
|
||||||
|
common.BytesToHash(mocks.RemovedLeafKey).Hex(): {
|
||||||
BlockNumber: mocks.BlockNumber.String(),
|
BlockNumber: mocks.BlockNumber.String(),
|
||||||
CID: shared.RemovedNodeStorageCID,
|
CID: shared.RemovedNodeStorageCID,
|
||||||
NodeType: 3,
|
NodeType: 3,
|
||||||
@ -550,7 +554,7 @@ func TestSQLXIndexer(t *testing.T) {
|
|||||||
StateKey: common.BytesToHash(mocks.ContractLeafKey).Hex(),
|
StateKey: common.BytesToHash(mocks.ContractLeafKey).Hex(),
|
||||||
Path: []byte{'\x03'},
|
Path: []byte{'\x03'},
|
||||||
},
|
},
|
||||||
{
|
common.BytesToHash(mocks.Storage2LeafKey).Hex(): {
|
||||||
BlockNumber: mocks.BlockNumber.String(),
|
BlockNumber: mocks.BlockNumber.String(),
|
||||||
CID: shared.RemovedNodeStorageCID,
|
CID: shared.RemovedNodeStorageCID,
|
||||||
NodeType: 3,
|
NodeType: 3,
|
||||||
@ -558,7 +562,7 @@ func TestSQLXIndexer(t *testing.T) {
|
|||||||
StateKey: common.BytesToHash(mocks.Contract2LeafKey).Hex(),
|
StateKey: common.BytesToHash(mocks.Contract2LeafKey).Hex(),
|
||||||
Path: []byte{'\x0e'},
|
Path: []byte{'\x0e'},
|
||||||
},
|
},
|
||||||
{
|
common.BytesToHash(mocks.Storage3LeafKey).Hex(): {
|
||||||
BlockNumber: mocks.BlockNumber.String(),
|
BlockNumber: mocks.BlockNumber.String(),
|
||||||
CID: shared.RemovedNodeStorageCID,
|
CID: shared.RemovedNodeStorageCID,
|
||||||
NodeType: 3,
|
NodeType: 3,
|
||||||
@ -567,8 +571,8 @@ func TestSQLXIndexer(t *testing.T) {
|
|||||||
Path: []byte{'\x0f'},
|
Path: []byte{'\x0f'},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for idx, storageNode := range storageNodes {
|
for storageKey, storageNode := range gotStorageNodes {
|
||||||
require.Equal(t, expectedStorageNodes[idx], storageNode)
|
require.Equal(t, expectedStorageNodes[storageKey], storageNode)
|
||||||
dc, err = cid.Decode(storageNode.CID)
|
dc, err = cid.Decode(storageNode.CID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user