-
Notifications
You must be signed in to change notification settings - Fork 12
/
storage_accountdiffs.go
36 lines (29 loc) · 1.16 KB
/
storage_accountdiffs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package testsuite
import (
"github.com/stretchr/testify/assert"
"github.com/iotaledger/hive.go/ierrors"
"github.com/iotaledger/iota-core/pkg/model"
"github.com/iotaledger/iota-core/pkg/testsuite/mock"
iotago "github.com/iotaledger/iota.go/v4"
)
func (t *TestSuite) AssertStorageAccountDiffs(slot iotago.SlotIndex, accountDiffs map[iotago.AccountID]*model.AccountDiff, nodes ...*mock.Node) {
mustNodes(nodes)
for _, node := range nodes {
for accountID, diffChange := range accountDiffs {
t.Eventually(func() error {
store, err := node.Protocol.Engines.Main.Get().Storage.AccountDiffs(slot)
if err != nil {
return ierrors.Wrapf(err, "AssertStorageAccountDiffs: %s: failed to load accounts diff for slot %d", node.Name, slot)
}
storedDiffChange, _, err := store.Load(accountID)
if err != nil {
return ierrors.Wrapf(err, "AssertStorageAccountDiffs: %s: error loading account diff: %s", node.Name, accountID)
}
if !assert.Equal(t.fakeTesting, diffChange, storedDiffChange) {
return ierrors.Errorf("AssertStorageAccountDiffs: %s: expected %v, got %v", node.Name, diffChange, storedDiffChange)
}
return nil
})
}
}
}