From 74cfafb87f27d2e41213339ebe46cd034b2fe6e3 Mon Sep 17 00:00:00 2001 From: songgaoye Date: Thu, 24 Jul 2025 17:56:09 +0800 Subject: [PATCH] fix p256 flaky test --- tests/integration/precompiles/p256/test_integration.go | 9 +++++---- tests/integration/precompiles/p256/test_p256.go | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/integration/precompiles/p256/test_integration.go b/tests/integration/precompiles/p256/test_integration.go index 4fefdac3b..54079e25f 100644 --- a/tests/integration/precompiles/p256/test_integration.go +++ b/tests/integration/precompiles/p256/test_integration.go @@ -170,10 +170,11 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp input = make([]byte, p256.VerifyInputLength) copy(input[0:32], hash) - copy(input[32:64], rInt.Bytes()) - copy(input[64:96], sInt.Bytes()) - copy(input[96:128], privB.PublicKey.X.Bytes()) - copy(input[128:160], privB.PublicKey.Y.Bytes()) + // ALWAYS left-pad to 32 bytes: + copy(input[32:64], common.LeftPadBytes(rInt.Bytes(), 32)) + copy(input[64:96], common.LeftPadBytes(sInt.Bytes(), 32)) + copy(input[96:128], common.LeftPadBytes(privB.PublicKey.X.Bytes(), 32)) + copy(input[128:160], common.LeftPadBytes(privB.PublicKey.Y.Bytes(), 32)) return input }, ), diff --git a/tests/integration/precompiles/p256/test_p256.go b/tests/integration/precompiles/p256/test_p256.go index d971be026..390d85ead 100644 --- a/tests/integration/precompiles/p256/test_p256.go +++ b/tests/integration/precompiles/p256/test_p256.go @@ -65,8 +65,9 @@ func (s *PrecompileTestSuite) TestRun() { input := make([]byte, p256.VerifyInputLength) copy(input[0:32], hash) - copy(input[32:64], rBz) - copy(input[64:96], sBz) + // ALWAYS left-pad to 32 bytes: + copy(input[32:64], common.LeftPadBytes(rBz, 32)) + copy(input[64:96], common.LeftPadBytes(sBz, 32)) s.p256Priv.X.FillBytes(input[96:128]) s.p256Priv.Y.FillBytes(input[128:160])