Skip to content

Commit cedc3ca

Browse files
authored
fix p256 flaky test (cosmos#350)
1 parent 460f435 commit cedc3ca

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

tests/integration/precompiles/p256/test_integration.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,11 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp
170170

171171
input = make([]byte, p256.VerifyInputLength)
172172
copy(input[0:32], hash)
173-
copy(input[32:64], rInt.Bytes())
174-
copy(input[64:96], sInt.Bytes())
175-
copy(input[96:128], privB.PublicKey.X.Bytes())
176-
copy(input[128:160], privB.PublicKey.Y.Bytes())
173+
// ALWAYS left-pad to 32 bytes:
174+
copy(input[32:64], common.LeftPadBytes(rInt.Bytes(), 32))
175+
copy(input[64:96], common.LeftPadBytes(sInt.Bytes(), 32))
176+
copy(input[96:128], common.LeftPadBytes(privB.PublicKey.X.Bytes(), 32))
177+
copy(input[128:160], common.LeftPadBytes(privB.PublicKey.Y.Bytes(), 32))
177178
return input
178179
},
179180
),

tests/integration/precompiles/p256/test_p256.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ func (s *PrecompileTestSuite) TestRun() {
6565

6666
input := make([]byte, p256.VerifyInputLength)
6767
copy(input[0:32], hash)
68-
copy(input[32:64], rBz)
69-
copy(input[64:96], sBz)
68+
// ALWAYS left-pad to 32 bytes:
69+
copy(input[32:64], common.LeftPadBytes(rBz, 32))
70+
copy(input[64:96], common.LeftPadBytes(sBz, 32))
7071
s.p256Priv.X.FillBytes(input[96:128])
7172
s.p256Priv.Y.FillBytes(input[128:160])
7273

0 commit comments

Comments
 (0)