Skip to content

Commit

Permalink
chore: update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RafilxTenfen committed Dec 6, 2024
1 parent 76116a5 commit 093349d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 30 deletions.
3 changes: 0 additions & 3 deletions app/upgrades/v1/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ func (s *UpgradeTestSuite) TestUpgrade() {
func (s *UpgradeTestSuite) SetupTest(upgradeDataStr v1.UpgradeDataString) {
s.upgradeDataStr = upgradeDataStr

// baseBtcHeaderHash := "00000020c8710c5662ab0a4680963697765a390cba4814f95f0556fc5fb3b446b2000000fa9b80e52653455e5d4a4648fbe1f62854a07dbec0633a42ef595431de9be36dccb64366934f011ef3d98200"
// TODO(rafilx): add this hash in setup suite app.

// add the upgrade plan
app.Upgrades = []upgrades.Upgrade{v1.CreateUpgrade(upgradeDataStr)}

Expand Down
18 changes: 6 additions & 12 deletions test/e2e/software_upgrade_e2e_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ func (s *SoftwareUpgradeV1TestnetTestSuite) SetupSuite() {
// func only runs right before the upgrade proposal is sent
preUpgradeFunc := func(chains []*chain.Config) {
node := chains[0].NodeConfigs[1]
uniqueAddrs := make(map[string]any)
uniqueAddrsToMint := make(map[string]any)
uniqueAddrsTokenReceivers := make(map[string]any)

for addr, amountToMint := range balanceToMintByAddr {
uniqueAddrs[addr] = struct{}{}
s.balancesBeforeUpgrade[addr] = sdk.NewCoin(appparams.DefaultBondDenom, sdkmath.ZeroInt())
if amountToMint <= 0 {
continue
}

uniqueAddrsToMint[addr] = struct{}{}
uniqueAddrsTokenReceivers[addr] = struct{}{}
amountToSend := sdk.NewCoin(appparams.BaseCoinUnit, sdkmath.NewInt(amountToMint))
node.BankSendFromNode(addr, amountToSend.String())
}
Expand All @@ -66,14 +65,9 @@ func (s *SoftwareUpgradeV1TestnetTestSuite) SetupSuite() {
// it queries the real balances before upgrade.
node.WaitForNextBlock()

// This does not work for 50k addresses
for addr := range uniqueAddrs {
// assume that the balance prior to upgrade of each addr is zero.
s.balancesBeforeUpgrade[addr] = sdk.NewCoin(appparams.DefaultBondDenom, sdkmath.ZeroInt())
}

// only verifies the ones that did received something
for addr := range uniqueAddrsToMint {
// only verifies the balances of the ones that had to receive something
// from the node and all the others should be zero
for addr := range uniqueAddrsTokenReceivers {
balance, err := node.QueryBalance(addr, appparams.DefaultBondDenom)
s.NoError(err)
s.balancesBeforeUpgrade[addr] = *balance
Expand Down
3 changes: 2 additions & 1 deletion testutil/sample/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ func AccAddress() string {
// SignetBtcHeader195552 returns the BTC Header block 195552 from signet bbn-test-4.
func SignetBtcHeader195552(t *testing.T) *btclighttypes.BTCHeaderInfo {
var btcHeader btclighttypes.BTCHeaderInfo
// signet btc header 0

// signet btc header of height 195552
btcHeaderHash, err := types.NewBTCHeaderBytesFromHex("00000020c8710c5662ab0a4680963697765a390cba4814f95f0556fc5fb3b446b2000000fa9b80e52653455e5d4a4648fbe1f62854a07dbec0633a42ef595431de9be36dccb64366934f011ef3d98200")
require.NoError(t, err)

Expand Down
16 changes: 2 additions & 14 deletions x/btclightclient/types/work_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,11 @@ func FuzzCumulativeWork(f *testing.F) {
}

func TestRetargetBlock(t *testing.T) {
btcNet := &chaincfg.SigNetParams
blockActivationHeight := uint32(197535)
expectedBaseBlockHeightTestnet := uint32(195552)
for {
if types.IsRetargetBlock(&types.BTCHeaderInfo{Height: blockActivationHeight}, btcNet) {
t.Logf("Block height: %d is the first retarget block since 197535", blockActivationHeight)
require.Equal(t, blockActivationHeight, expectedBaseBlockHeightTestnet)
break
}
blockActivationHeight--
}
// cap1 testnet starts at 197535, not good
require.True(t, types.IsRetargetBlock(&types.BTCHeaderInfo{Height: expectedBaseBlockHeightTestnet}, &chaincfg.SigNetParams))
expectedBaseBlockHeightTestnet4 := uint32(195552)
require.True(t, types.IsRetargetBlock(&types.BTCHeaderInfo{Height: expectedBaseBlockHeightTestnet4}, &chaincfg.SigNetParams))

baseBtcHeaderMainnetHeight := uint32(854784)
cap1ActivationHeight := uint32(857910)
require.True(t, types.IsRetargetBlock(&types.BTCHeaderInfo{Height: baseBtcHeaderMainnetHeight}, &chaincfg.MainNetParams))
require.True(t, baseBtcHeaderMainnetHeight < cap1ActivationHeight)
// cap1 mainnet starts at 857910, good
}

0 comments on commit 093349d

Please sign in to comment.