@@ -16,6 +16,7 @@ import (
1616func RunTests (t * testing.T , s ram.Store , teardown func ()) {
1717 for _ , tf := range []func (t * testing.T , s ram.Store ){
1818 testRoundTrip ,
19+ testGetAllMemoryAccounts ,
1920 testGetAllByMemoryAccount ,
2021 testGetAllVirtualAccountsByAddressAndType ,
2122 } {
@@ -33,10 +34,10 @@ func testRoundTrip(t *testing.T, s ram.Store) {
3334 accountType := cvm .VirtualAccountTypeTimelock
3435
3536 _ , err := s .GetAllVirtualAccountsByAddressAndType (ctx , address , accountType )
36- assert .Equal (t , ram .ErrNotFound , err )
37+ assert .Equal (t , ram .ErrItemNotFound , err )
3738
3839 _ , err = s .GetAllByMemoryAccount (ctx , memoryAccount )
39- assert .Equal (t , ram .ErrNotFound , err )
40+ assert .Equal (t , ram .ErrItemNotFound , err )
4041
4142 start := time .Now ()
4243
@@ -91,7 +92,7 @@ func testRoundTrip(t *testing.T, s ram.Store) {
9192 require .NoError (t , s .Save (ctx , expected ))
9293
9394 _ , err = s .GetAllVirtualAccountsByAddressAndType (ctx , address , accountType )
94- assert .Equal (t , ram .ErrNotFound , err )
95+ assert .Equal (t , ram .ErrItemNotFound , err )
9596
9697 actual , err = s .GetAllByMemoryAccount (ctx , memoryAccount )
9798 require .NoError (t , err )
@@ -100,6 +101,32 @@ func testRoundTrip(t *testing.T, s ram.Store) {
100101 })
101102}
102103
104+ func testGetAllMemoryAccounts (t * testing.T , s ram.Store ) {
105+ t .Run ("testGetAllMemoryAccounts" , func (t * testing.T ) {
106+ ctx := context .Background ()
107+
108+ _ , err := s .GetAllMemoryAccounts (ctx , "vm2" )
109+ assert .Equal (t , ram .ErrAccountNotFound , err )
110+
111+ for i := 0 ; i < 3 ; i ++ {
112+ require .NoError (t , s .Save (ctx , & ram.Record {
113+ Vm : fmt .Sprintf ("vm%d" , i ),
114+
115+ MemoryAccount : fmt .Sprintf ("memory_account_%d" , i ),
116+ Index : 12345 ,
117+ IsAllocated : false ,
118+
119+ Slot : 12345 ,
120+ }))
121+ }
122+
123+ actual , err := s .GetAllMemoryAccounts (ctx , "vm2" )
124+ require .NoError (t , err )
125+ require .Len (t , actual , 1 )
126+ assert .Equal (t , "memory_account_2" , actual [0 ])
127+ })
128+ }
129+
103130func testGetAllByMemoryAccount (t * testing.T , s ram.Store ) {
104131 t .Run ("testGetAllByMemoryAccount" , func (t * testing.T ) {
105132 ctx := context .Background ()
0 commit comments