Skip to content

Commit

Permalink
uses regtest everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazar955 committed Aug 12, 2024
1 parent 0b0535c commit ca35e3d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions e2etest/atomicslasher_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestAtomicSlasher(t *testing.T) {
finality provider builds slashing tx witness and sends slashing tx to Bitcoin
*/
victimBTCDel := btcDels[0]
victimSlashingTx, err := btcslasher.BuildSlashingTxWithWitness(victimBTCDel, &bsParams, netParams, fpSK)
victimSlashingTx, err := btcslasher.BuildSlashingTxWithWitness(victimBTCDel, &bsParams, regtestParams, fpSK)
// send slashing tx to Bitcoin
require.NoError(t, err)
slashingTxHash, err := tm.BTCClient.SendRawTransaction(victimSlashingTx, true)
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestAtomicSlasher_Unbonding(t *testing.T) {
/*
finality provider builds unbonding slashing tx witness and sends it to Bitcoin
*/
victimUnbondingSlashingTx, err := btcslasher.BuildUnbondingSlashingTxWithWitness(victimBTCDel, &bsParams, netParams, fpSK)
victimUnbondingSlashingTx, err := btcslasher.BuildUnbondingSlashingTxWithWitness(victimBTCDel, &bsParams, regtestParams, fpSK)
require.NoError(t, err)

// send slashing tx to Bitcoin
Expand Down
4 changes: 3 additions & 1 deletion e2etest/babylon_node_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ type BabylonNodeHandler struct {
babylonNode *babylonNode
}

func NewBabylonNodeHandler(baseHeaderHex string) (*BabylonNodeHandler, error) {
func NewBabylonNodeHandler(baseHeaderHex string, slashingAddress string) (*BabylonNodeHandler, error) {
testDir, err := baseDirBabylondir()
if err != nil {
return nil, err
Expand All @@ -140,6 +140,8 @@ func NewBabylonNodeHandler(baseHeaderHex string) (*BabylonNodeHandler, error) {
"--btc-finalization-timeout=4",
"--btc-confirmation-depth=2",
"--additional-sender-account",
"--btc-network=regtest",
fmt.Sprintf("--slashing-address=%s", slashingAddress),
fmt.Sprintf("--btc-base-header=%s", baseHeaderHex),
"--covenant-quorum=1",
fmt.Sprintf("--covenant-pks=%s", bbn.NewBIP340PubKeyFromBTCPK(juryPK).MarshalHex()),
Expand Down
11 changes: 5 additions & 6 deletions e2etest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

// bticoin params used for testing
var (
netParams = &chaincfg.SimNetParams
submitterAddrStr = "bbn1eppc73j56382wjn6nnq3quu5eye4pmm087xfdh" //nolint:unused
babylonTag = []byte{1, 2, 3, 4} //nolint:unused
babylonTagHex = hex.EncodeToString(babylonTag) //nolint:unused
Expand All @@ -39,7 +38,7 @@ var (
func defaultVigilanteConfig() *config.Config {
defaultConfig := config.DefaultConfig()
// Config setting necessary to connect btcd daemon
defaultConfig.BTC.NetParams = "regtest"
defaultConfig.BTC.NetParams = regtestParams.Name
defaultConfig.BTC.Endpoint = "127.0.0.1:18443"
// Config setting necessary to connect btcwallet daemon
defaultConfig.BTC.BtcBackend = types.Bitcoind
Expand Down Expand Up @@ -113,8 +112,11 @@ func StartManager(t *testing.T, numMatureOutputsInWallet uint32) *TestManager {
require.NoError(t, err)
baseHeaderHex := hex.EncodeToString(buff.Bytes())

minerAddressDecoded, err := btcutil.DecodeAddress(blocksResponse.Address, regtestParams)
require.NoError(t, err)

// start Babylon node
bh, err := NewBabylonNodeHandler(baseHeaderHex)
bh, err := NewBabylonNodeHandler(baseHeaderHex, minerAddressDecoded.EncodeAddress())
require.NoError(t, err)
err = bh.Start()
require.NoError(t, err)
Expand All @@ -140,9 +142,6 @@ func StartManager(t *testing.T, numMatureOutputsInWallet uint32) *TestManager {
err = testRpcClient.WalletPassphrase(passphrase, 600)
require.NoError(t, err)

minerAddressDecoded, err := btcutil.DecodeAddress(blocksResponse.Address, regtestParams)
require.NoError(t, err)

walletPrivKey, err := testRpcClient.DumpPrivKey(minerAddressDecoded)
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions e2etest/test_manager_btcstaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (tm *TestManager) CreateBTCDelegation(
stakingSlashingInfo := datagen.GenBTCStakingSlashingInfoWithOutPoint(
r,
t,
netParams,
regtestParams,
topUTXO.GetOutPoint(),
tm.WalletPrivKey,
[]*btcec.PublicKey{fpPK},
Expand Down Expand Up @@ -188,7 +188,7 @@ func (tm *TestManager) CreateBTCDelegation(
unbondingSlashingInfo := datagen.GenBTCUnbondingSlashingInfo(
r,
t,
netParams,
regtestParams,
tm.WalletPrivKey,
[]*btcec.PublicKey{fpPK},
covenantBtcPks,
Expand Down

0 comments on commit ca35e3d

Please sign in to comment.