Skip to content

Commit

Permalink
Add partitiontest to tests. (#3658)
Browse files Browse the repository at this point in the history
## Summary

We seem to have missed a few of these. We have a partitiontest linter, it seems that isn't working since we missed all of these.

## Test Plan

Check the result of `_test_verification` to make sure this is all of the ones we missed.
  • Loading branch information
winder authored Feb 18, 2022
1 parent 468d34b commit fe43b24
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
18 changes: 18 additions & 0 deletions crypto/secp256k1/secp256_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"encoding/hex"
"io"
"testing"

"github.com/algorand/go-algorand/test/partitiontest"
)

const TestCount = 1000
Expand Down Expand Up @@ -84,6 +86,8 @@ func TestSignatureValidity(t *testing.T) {
}

func TestInvalidRecoveryID(t *testing.T) {
partitiontest.PartitionTest(t)

_, seckey := generateKeyPair()
msg := csprngEntropy(32)
sig, _ := Sign(msg, seckey)
Expand All @@ -95,6 +99,8 @@ func TestInvalidRecoveryID(t *testing.T) {
}

func TestSignAndRecover(t *testing.T) {
partitiontest.PartitionTest(t)

pubkey1, seckey := generateKeyPair()
msg := csprngEntropy(32)
sig, err := Sign(msg, seckey)
Expand All @@ -111,6 +117,8 @@ func TestSignAndRecover(t *testing.T) {
}

func TestSignDeterministic(t *testing.T) {
partitiontest.PartitionTest(t)

_, seckey := generateKeyPair()
msg := make([]byte, 32)
copy(msg, "hi there")
Expand All @@ -129,6 +137,8 @@ func TestSignDeterministic(t *testing.T) {
}

func TestRandomMessagesWithSameKey(t *testing.T) {
partitiontest.PartitionTest(t)

pubkey, seckey := generateKeyPair()
keys := func() ([]byte, []byte) {
return pubkey, seckey
Expand All @@ -137,6 +147,8 @@ func TestRandomMessagesWithSameKey(t *testing.T) {
}

func TestRandomMessagesWithRandomKeys(t *testing.T) {
partitiontest.PartitionTest(t)

keys := func() ([]byte, []byte) {
pubkey, seckey := generateKeyPair()
return pubkey, seckey
Expand Down Expand Up @@ -174,6 +186,8 @@ func signAndRecoverWithRandomMessages(t *testing.T, keys func() ([]byte, []byte)
}

func TestRecoveryOfRandomSignature(t *testing.T) {
partitiontest.PartitionTest(t)

pubkey1, _ := generateKeyPair()
msg := csprngEntropy(32)

Expand All @@ -187,6 +201,8 @@ func TestRecoveryOfRandomSignature(t *testing.T) {
}

func TestRandomMessagesAgainstValidSig(t *testing.T) {
partitiontest.PartitionTest(t)

pubkey1, seckey := generateKeyPair()
msg := csprngEntropy(32)
sig, _ := Sign(msg, seckey)
Expand All @@ -204,6 +220,8 @@ func TestRandomMessagesAgainstValidSig(t *testing.T) {
// Useful when the underlying libsecp256k1 API changes to quickly
// check only recover function without use of signature function
func TestRecoverSanity(t *testing.T) {
partitiontest.PartitionTest(t)

msg, _ := hex.DecodeString("ce0677bb30baa8cf067c88db9811f4333d131bf8bcf12fe7065d211dce971008")
sig, _ := hex.DecodeString("90f27b8b488db00b00606796d2987f6a5f59ae62ea05effe84fef5b8b0e549984a691139ad57a3f0b906637673aa2f63d1f55cb1a69199d4009eea23ceaddc9301")
pubkey1, _ := hex.DecodeString("04e32df42865e97135acfb65f3bae71bdc86f4d49150ad6a440b6f15878109880a0a2b2667f7e725ceea70c673093bf67663e0312623c8e091b13cf2c0f11ef652")
Expand Down
Loading

0 comments on commit fe43b24

Please sign in to comment.