prysm-pulse/beacon-chain/db/kv/deposit_contract_test.go
Raul Jordan 3ca4d6fd91
Add Deposit Contract Methods to DB Refactor (#3264)
* new interface methods

* support proposer slashings

* add in the new buckets

* all crud for propoer slashings

* attester slashings complete

* all slashings crud done

* right comment

* deposit contract tests pass

* delete out of scope methods

* conform old beacon DB

* comment

* deprecations

* pass lint

* Update deposit_contract.go
2019-08-21 16:11:50 -05:00

37 lines
948 B
Go

package kv
import (
"context"
"testing"
"github.com/ethereum/go-ethereum/common"
)
func TestStore_DepositContract(t *testing.T) {
db := setupDB(t)
defer teardownDB(t, db)
ctx := context.Background()
contractAddress := common.Address{1, 2, 3}
retrieved, err := db.DepositContractAddress(ctx)
if err != nil {
t.Fatal(err)
}
if retrieved != nil {
t.Errorf("Expected nil contract address, received %v", retrieved)
}
if err := db.SaveDepositContractAddress(ctx, contractAddress); err != nil {
t.Fatal(err)
}
retrieved, err = db.DepositContractAddress(ctx)
if err != nil {
t.Fatal(err)
}
if common.BytesToAddress(retrieved) != contractAddress {
t.Errorf("Expected address %#x, received %#x", contractAddress, retrieved)
}
otherAddress := common.Address{4, 5, 6}
if err := db.SaveDepositContractAddress(ctx, otherAddress); err == nil {
t.Error("Should not have been able to override old deposit contract address")
}
}