mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 05:17:22 +00:00
b5c4dc2a75
* init-sync updates * slasher/db/kv tests * beacon-chain/rpc/beacon tests * update kv_test * beacon-chain/rpc-validator tests updated * slasher/db/kv - remove teardown method * beacon-chain/sync tests updated * beacon-chain/db/kv tests updated * beacon-chain/blockchain tests updated * beacon-chain/state/stategen tests updated * beacon-chain/powchain updates * updates rest of slasher tests * validator/db tests * rest of the tests * minor comments update * gazelle * Merge refs/heads/master into teardowndb-to-cleanup
36 lines
923 B
Go
36 lines
923 B
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
)
|
|
|
|
func TestStore_DepositContract(t *testing.T) {
|
|
db := setupDB(t)
|
|
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")
|
|
}
|
|
}
|