Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
RafilxTenfen committed Nov 21, 2024
1 parent 35ec159 commit 81b947b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 29 deletions.
7 changes: 2 additions & 5 deletions cmd/stakercli/transaction/transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ var (
Versions: []*parser.VersionedGlobalParams{&defaultParam},
}

//nolint:errchkjson
paramsMarshalled, _ = json.Marshal(globalParams)

parsedGlobalParams, _ = parser.ParseGlobalParams(&globalParams)
lastParams = parsedGlobalParams.Versions[len(parsedGlobalParams.Versions)-1]
)
Expand Down Expand Up @@ -189,8 +186,8 @@ func appRunCreatePhase1WithdrawalTx(r *rand.Rand, t *testing.T, app *cli.App, ar
return data
}

func randRange(_ *rand.Rand, min, max int) int {
return rand.Intn(max+1-min) + min
func randRange(_ *rand.Rand, minV, maxV int) int {
return rand.Intn(maxV+1-minV) + minV
}

type StakeParameters struct {
Expand Down
16 changes: 4 additions & 12 deletions itest/containers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,11 @@ func (m *Manager) RunBabylondResource(
coventantQuorum int,
baseHeaderHex string,
slashingPkScript string,
covenantPk1 *btcec.PublicKey,
covenantPk2 *btcec.PublicKey,
covenantPk3 *btcec.PublicKey,
covenantPks ...*btcec.PublicKey,
) (*dockertest.Resource, error) {
covenantPks := []*bbn.BIP340PubKey{
bbn.NewBIP340PubKeyFromBTCPK(covenantPk1),
bbn.NewBIP340PubKeyFromBTCPK(covenantPk2),
bbn.NewBIP340PubKeyFromBTCPK(covenantPk3),
}

var covenantPksStr []string
for _, pk := range covenantPks {
covenantPksStr = append(covenantPksStr, pk.MarshalHex())
covenantPksStr := make([]string, len(covenantPks))
for i, cvPk := range covenantPks {
covenantPksStr[i] = bbn.NewBIP340PubKeyFromBTCPK(cvPk).MarshalHex()
}

cmd := []string{
Expand Down
5 changes: 4 additions & 1 deletion itest/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,5 +931,8 @@ func TestStakeFromPhase1(t *testing.T) {
stkTxResult, err := rpcBtc.GetTransaction(txHash)
require.NoError(t, err)
require.NotNil(t, stkTxResult)
// tm.createAndRegisterFinalityProviders(t, testStakingData)

// at this point the BTC staking transaction is confirmed and was mined in BTC
// so the babylon chain can start and try to transition this staking BTC tx
// into a babylon BTC delegation in the cosmos side.
}
44 changes: 33 additions & 11 deletions itest/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ func btcRpcTestClient(t *testing.T, bitcoindHost string) *rpcclient.Client {
}

type TestManager struct {
manager *containers.Manager
TestManagerStakerApp
TestManagerBTC
}

type TestManagerStakerApp struct {
Config *stakercfg.Config
Db kvdb.Backend
Sa *staker.App
Expand All @@ -154,8 +160,6 @@ type TestManager struct {
serviceAddress string
StakerClient *dc.StakerServiceJSONRPCClient
CovenantPrivKeys []*btcec.PrivateKey
manager *containers.Manager
TestManagerBTC
}

type TestManagerBTC struct {
Expand Down Expand Up @@ -305,10 +309,32 @@ func StartManager(
tmBTC := StartManagerBtc(t, ctx, numMatureOutputsInWallet, manager)

quorum := 2
coventantPrivKeys := genCovenants(t, 3)
covenantsNum := 3
tmStakerApp := StartManagerStakerApp(t, ctx, tmBTC, manager, quorum, covenantsNum)

return &TestManager{
manager: manager,
TestManagerStakerApp: *tmStakerApp,
TestManagerBTC: *tmBTC,
}
}

func StartManagerStakerApp(
t *testing.T,
ctx context.Context,
tmBTC *TestManagerBTC,
manager *containers.Manager,
covenantQuorum int,
covenantNum int,
) *TestManagerStakerApp {
coventantPrivKeys := genCovenants(t, covenantNum)
coventantPubKeys := make([]*btcec.PublicKey, covenantNum)
for i, cvPrivKey := range coventantPrivKeys {
coventantPubKeys[i] = cvPrivKey.PubKey()
}

var buff bytes.Buffer
err = regtestParams.GenesisBlock.Header.Serialize(&buff)
err := regtestParams.GenesisBlock.Header.Serialize(&buff)
require.NoError(t, err)
baseHeaderHex := hex.EncodeToString(buff.Bytes())

Expand All @@ -320,12 +346,10 @@ func StartManager(
babylond, err := manager.RunBabylondResource(
t,
tmpDir,
quorum,
covenantQuorum,
baseHeaderHex,
hex.EncodeToString(pkScript), // all slashing will be sent back to wallet
coventantPrivKeys[0].PubKey(),
coventantPrivKeys[1].PubKey(),
coventantPrivKeys[2].PubKey(),
coventantPubKeys...,
)
require.NoError(t, err)

Expand Down Expand Up @@ -391,7 +415,7 @@ func StartManager(
stakerClient, err := dc.NewStakerServiceJSONRPCClient("tcp://" + addressString)
require.NoError(t, err)

return &TestManager{
return &TestManagerStakerApp{
Config: cfg,
Db: dbbackend,
Sa: stakerApp,
Expand All @@ -400,8 +424,6 @@ func StartManager(
serviceAddress: addressString,
StakerClient: stakerClient,
CovenantPrivKeys: coventantPrivKeys,
manager: manager,
TestManagerBTC: *tmBTC,
}
}

Expand Down

0 comments on commit 81b947b

Please sign in to comment.