ipld-eth-server/pkg/fakes/mock_fs_reader.go
Rob Mulholand d5c2ab33fc Sync only missing blocks on cold import
= Add eth_node_fingerprint to block that can be imitated by both hot and cold imports
- Only sync missing blocks (blocks that are missing or don't share a fingerprint) on cold import
- Set block is_final status after import
2018-05-07 16:38:04 -05:00

39 lines
822 B
Go

package fakes
import . "github.com/onsi/gomega"
type MockFsReader struct {
readCalled bool
readPassedPath string
readReturnBytes []byte
readReturnErr error
}
func NewMockFsReader() *MockFsReader {
return &MockFsReader{
readCalled: false,
readPassedPath: "",
readReturnBytes: nil,
readReturnErr: nil,
}
}
func (mfr *MockFsReader) SetReturnBytes(returnBytes []byte) {
mfr.readReturnBytes = returnBytes
}
func (mfr *MockFsReader) SetReturnErr(err error) {
mfr.readReturnErr = err
}
func (mfr *MockFsReader) Read(path string) ([]byte, error) {
mfr.readCalled = true
mfr.readPassedPath = path
return mfr.readReturnBytes, mfr.readReturnErr
}
func (mfr *MockFsReader) AssertReadCalledWith(path string) {
Expect(mfr.readCalled).To(BeTrue())
Expect(mfr.readPassedPath).To(Equal(path))
}