Skip to content

Commit

Permalink
feat: e2e privacy integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Alok committed Apr 12, 2024
1 parent a4379d2 commit 0993e18
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,18 @@ func (s *Store) PendingTxnCount() (int, error) {
}

func (s *Store) LastBlock() (uint64, error) {
var lastBlock uint64
var lastBlock sql.NullInt64
err := s.db.QueryRow("SELECT value FROM integers WHERE key = 'last_block'").Scan(&lastBlock)
if err != nil {
if err == sql.ErrNoRows {
return 0, nil
}
return 0, err
}
return lastBlock, nil
if !lastBlock.Valid {
return 0, nil
}
return uint64(lastBlock.Int64), nil
}

func (s *Store) SetLastBlock(blockNum uint64) error {
Expand Down
28 changes: 28 additions & 0 deletions pkg/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,34 @@ func TestStore(t *testing.T) {
}
})

t.Run("LastBlock and SetBlockNo", func(t *testing.T) {
st, err := store.NewStore(db)
if err != nil {
t.Fatalf("Failed to create store: %s", err)
}

lastBlock, err := st.LastBlock()
if err != nil {
t.Fatalf("Failed to get last block: %s", err)
}
if lastBlock != 0 {
t.Fatalf("Expected last block 0, got %d", lastBlock)
}

err = st.SetLastBlock(3)
if err != nil {
t.Fatalf("Failed to set block number: %s", err)
}

lastBlock, err = st.LastBlock()
if err != nil {
t.Fatalf("Failed to get last block: %s", err)
}
if lastBlock != 3 {
t.Fatalf("Expected last block 3, got %d", lastBlock)
}
})

t.Run("MarkSettlementComplete", func(t *testing.T) {
st, err := store.NewStore(db)
if err != nil {
Expand Down

0 comments on commit 0993e18

Please sign in to comment.