Skip to content

Commit cfef2bb

Browse files
committed
tests: added tests for tx verification chain namespace for CEA->UEA
1 parent a2971e9 commit cfef2bb

File tree

3 files changed

+89
-13
lines changed

3 files changed

+89
-13
lines changed

test/integration/uexecutor/inbound_cea_gas_and_payload_test.go

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,43 @@ func TestInboundCEAGasAndPayload(t *testing.T) {
464464
"UEA should have received tokens via GAS_AND_PAYLOAD CEA deposit")
465465
})
466466

467-
t.Run("verified payload hash stores UEA owner as sender when isCEA is true for GAS_AND_PAYLOAD", func(t *testing.T) {
467+
t.Run("verified payload hash stored under UEA origin chain with UEA owner as sender for CEA GAS_AND_PAYLOAD", func(t *testing.T) {
468468
chainApp, ctx, vals, _, coreVals, ueaAddrHex := setupInboundCEAGasAndPayloadTest(t, 4)
469469
usdcAddress := utils.GetDefaultAddresses().ExternalUSDCAddr
470+
prc20Address := utils.GetDefaultAddresses().PRC20USDCAddr
470471
testAddress := utils.GetDefaultAddresses().DefaultTestAddr
471472

472-
// person B — a different sender that is NOT the UEA owner
473+
// Register a second chain (eip155:97) so we can send a CEA inbound from a different chain
474+
chainApp.UregistryKeeper.AddChainConfig(ctx, &uregistrytypes.ChainConfig{
475+
Chain: "eip155:97",
476+
VmType: uregistrytypes.VmType_EVM,
477+
PublicRpcUrl: "https://data-seed-prebsc-1-s1.binance.org:8545",
478+
GatewayAddress: "0x0000000000000000000000000000000000000000",
479+
BlockConfirmation: &uregistrytypes.BlockConfirmation{
480+
FastInbound: 5,
481+
StandardInbound: 12,
482+
},
483+
Enabled: &uregistrytypes.ChainEnabled{
484+
IsInboundEnabled: true,
485+
IsOutboundEnabled: true,
486+
},
487+
})
488+
chainApp.UregistryKeeper.AddTokenConfig(ctx, &uregistrytypes.TokenConfig{
489+
Chain: "eip155:97",
490+
Address: usdcAddress.String(),
491+
Name: "USD Coin",
492+
Symbol: "USDC",
493+
Decimals: 6,
494+
Enabled: true,
495+
LiquidityCap: "1000000000000000000000000",
496+
TokenType: 1,
497+
NativeRepresentation: &uregistrytypes.NativeRepresentation{
498+
Denom: "",
499+
ContractAddress: prc20Address.String(),
500+
},
501+
})
502+
503+
// person B — a different sender on a different chain
473504
personBSender := utils.GetDefaultAddresses().TargetAddr2
474505

475506
validUP := &uexecutortypes.UniversalPayload{
@@ -484,8 +515,9 @@ func TestInboundCEAGasAndPayload(t *testing.T) {
484515
VType: uexecutortypes.VerificationType(1),
485516
}
486517

518+
// CEA inbound from eip155:97, but UEA origin is eip155:11155111
487519
ceaInbound := &uexecutortypes.Inbound{
488-
SourceChain: "eip155:11155111",
520+
SourceChain: "eip155:97",
489521
TxHash: "0xceagas07",
490522
Sender: personBSender,
491523
Recipient: ueaAddrHex.String(),
@@ -510,12 +542,18 @@ func TestInboundCEAGasAndPayload(t *testing.T) {
510542
require.NoError(t, err)
511543
}
512544

513-
// Verify the stored sender in VerifiedTxMetadata is the UEA owner, not personBSender
514-
verified, found, err := chainApp.UtxverifierKeeper.GetVerifiedInboundTxMetadata(ctx, ceaInbound.SourceChain, ceaInbound.TxHash)
545+
// Payload hash should be stored under UEA origin chain (eip155:11155111), NOT source chain (eip155:97)
546+
ueaOriginChain := "eip155:11155111"
547+
verified, found, err := chainApp.UtxverifierKeeper.GetVerifiedInboundTxMetadata(ctx, ueaOriginChain, ceaInbound.TxHash)
515548
require.NoError(t, err)
516-
require.True(t, found, "verified tx metadata should exist after execution")
549+
require.True(t, found, "verified tx metadata should be stored under UEA origin chain")
517550
require.NotEmpty(t, verified.PayloadHashes, "payload hashes should be stored")
518551

552+
// Should NOT be found under source chain
553+
_, foundUnderSource, err := chainApp.UtxverifierKeeper.GetVerifiedInboundTxMetadata(ctx, ceaInbound.SourceChain, ceaInbound.TxHash)
554+
require.NoError(t, err)
555+
require.False(t, foundUnderSource, "verified tx metadata should NOT be stored under inbound source chain for CEA")
556+
519557
// The sender should be the UEA owner (testAddress), NOT personBSender
520558
require.NotEqual(t, personBSender, verified.Sender,
521559
"stored sender should NOT be the CEA executor")

test/integration/uexecutor/inbound_cea_payload_test.go

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,12 +693,43 @@ func TestInboundCEAFundsAndPayload(t *testing.T) {
693693
"isCEA=true should succeed using recipient UEA directly, ignoring whether sender has a UEA")
694694
})
695695

696-
t.Run("verified payload hash stores UEA owner as sender when isCEA is true for FUNDS_AND_PAYLOAD", func(t *testing.T) {
696+
t.Run("verified payload hash stored under UEA origin chain with UEA owner as sender for CEA FUNDS_AND_PAYLOAD", func(t *testing.T) {
697697
chainApp, ctx, vals, _, coreVals, ueaAddrHex := setupInboundCEAPayloadTest(t, 4)
698698
usdcAddress := utils.GetDefaultAddresses().ExternalUSDCAddr
699+
prc20Address := utils.GetDefaultAddresses().PRC20USDCAddr
699700
testAddress := utils.GetDefaultAddresses().DefaultTestAddr
700701

701-
// person B — a different sender that is NOT the UEA owner
702+
// Register a second chain (eip155:97) so we can send a CEA inbound from a different chain
703+
chainApp.UregistryKeeper.AddChainConfig(ctx, &uregistrytypes.ChainConfig{
704+
Chain: "eip155:97",
705+
VmType: uregistrytypes.VmType_EVM,
706+
PublicRpcUrl: "https://data-seed-prebsc-1-s1.binance.org:8545",
707+
GatewayAddress: "0x0000000000000000000000000000000000000000",
708+
BlockConfirmation: &uregistrytypes.BlockConfirmation{
709+
FastInbound: 5,
710+
StandardInbound: 12,
711+
},
712+
Enabled: &uregistrytypes.ChainEnabled{
713+
IsInboundEnabled: true,
714+
IsOutboundEnabled: true,
715+
},
716+
})
717+
chainApp.UregistryKeeper.AddTokenConfig(ctx, &uregistrytypes.TokenConfig{
718+
Chain: "eip155:97",
719+
Address: usdcAddress.String(),
720+
Name: "USD Coin",
721+
Symbol: "USDC",
722+
Decimals: 6,
723+
Enabled: true,
724+
LiquidityCap: "1000000000000000000000000",
725+
TokenType: 1,
726+
NativeRepresentation: &uregistrytypes.NativeRepresentation{
727+
Denom: "",
728+
ContractAddress: prc20Address.String(),
729+
},
730+
})
731+
732+
// person B — a different sender on a different chain
702733
personBSender := utils.GetDefaultAddresses().TargetAddr2
703734

704735
validUP := &uexecutortypes.UniversalPayload{
@@ -713,8 +744,9 @@ func TestInboundCEAFundsAndPayload(t *testing.T) {
713744
VType: uexecutortypes.VerificationType(1),
714745
}
715746

747+
// CEA inbound from eip155:97, but UEA origin is eip155:11155111
716748
ceaInbound := &uexecutortypes.Inbound{
717-
SourceChain: "eip155:11155111",
749+
SourceChain: "eip155:97",
718750
TxHash: "0xcea07",
719751
Sender: personBSender,
720752
Recipient: ueaAddrHex.String(),
@@ -739,12 +771,18 @@ func TestInboundCEAFundsAndPayload(t *testing.T) {
739771
require.NoError(t, err)
740772
}
741773

742-
// Verify the stored sender in VerifiedTxMetadata is the UEA owner, not personBSender
743-
verified, found, err := chainApp.UtxverifierKeeper.GetVerifiedInboundTxMetadata(ctx, ceaInbound.SourceChain, ceaInbound.TxHash)
774+
// Payload hash should be stored under UEA origin chain (eip155:11155111), NOT source chain (eip155:97)
775+
ueaOriginChain := "eip155:11155111"
776+
verified, found, err := chainApp.UtxverifierKeeper.GetVerifiedInboundTxMetadata(ctx, ueaOriginChain, ceaInbound.TxHash)
744777
require.NoError(t, err)
745-
require.True(t, found, "verified tx metadata should exist after execution")
778+
require.True(t, found, "verified tx metadata should be stored under UEA origin chain")
746779
require.NotEmpty(t, verified.PayloadHashes, "payload hashes should be stored")
747780

781+
// Should NOT be found under source chain
782+
_, foundUnderSource, err := chainApp.UtxverifierKeeper.GetVerifiedInboundTxMetadata(ctx, ceaInbound.SourceChain, ceaInbound.TxHash)
783+
require.NoError(t, err)
784+
require.False(t, foundUnderSource, "verified tx metadata should NOT be stored under inbound source chain for CEA")
785+
748786
// The sender should be the UEA owner (testAddress), NOT personBSender
749787
require.NotEqual(t, personBSender, verified.Sender,
750788
"stored sender should NOT be the CEA executor")

test/integration/uexecutor/inbound_synthetic_bridge_payload_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func TestInboundSyntheticBridgePayload(t *testing.T) {
317317

318318
// Call your function to compute and store payload hash
319319
ueModuleAddr, _ := app.UexecutorKeeper.GetUeModuleAddress(ctx)
320-
err = app.UexecutorKeeper.StoreVerifiedPayloadHash(ctx, utx, ueaAddrHex, ueModuleAddr, utx.InboundTx.Sender)
320+
err = app.UexecutorKeeper.StoreVerifiedPayloadHash(ctx, utx, ueaAddrHex, ueModuleAddr, utx.InboundTx.Sender, utx.InboundTx.SourceChain)
321321
require.NoError(t, err)
322322

323323
// Verify payload hash stored in utxverifier

0 commit comments

Comments
 (0)