core/state: add Size() method to NEP5TransferLog

This commit is contained in:
Evgenii Stratonikov 2020-03-12 12:32:24 +03:00
parent df2598c8dc
commit 3c6d9653b0
2 changed files with 7 additions and 0 deletions

View file

@ -106,6 +106,11 @@ func (lg *NEP5TransferLog) ForEach(f func(*NEP5Transfer) error) error {
return nil
}
// Size returns an amount of transfer written in log.
func (lg *NEP5TransferLog) Size() int {
return len(lg.Raw) / NEP5TransferSize
}
// EncodeBinary implements io.Serializable interface.
func (t *NEP5Tracker) EncodeBinary(w *io.BinWriter) {
w.WriteU64LE(uint64(t.Balance))

View file

@ -25,6 +25,8 @@ func TestNEP5TransferLog_Append(t *testing.T) {
require.NoError(t, lg.Append(tr))
}
require.Equal(t, len(expected), lg.Size())
i := 0
err := lg.ForEach(func(tr *NEP5Transfer) error {
require.Equal(t, expected[i], tr)