Skip to content

Commit

Permalink
imp: improved RemoveFeeMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
srdtrk committed May 7, 2024
1 parent 0250262 commit 0ac2e98
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions modules/apps/29-fee/fee_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package fee_test

import (
"reflect"
"testing"
"unsafe"

testifysuite "github.com/stretchr/testify/suite"

Expand Down Expand Up @@ -75,17 +73,7 @@ func RemoveFeeMiddleware(chain *ibctesting.TestChain) {
channelKeeper := chain.GetSimApp().IBCKeeper.ChannelKeeper

// Unseal the IBC router by force
r := reflect.ValueOf(chain.GetSimApp().IBCKeeper.PortKeeper.Router).Elem()

f := r.FieldByName("sealed")
if !f.IsValid() {
panic("field not found")
}
if !f.CanSet() { // Check if we can set the field
f = reflect.NewAt(f.Type(), unsafe.Pointer(f.UnsafeAddr())).Elem()
}

f.SetBool(false) // Use reflection to bypass unexported status
chain.GetSimApp().IBCKeeper.PortKeeper.Router = nil

newRouter := porttypes.NewRouter() // Create a new router
// Remove Fee middleware from transfer module
Expand Down

0 comments on commit 0ac2e98

Please sign in to comment.