Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: add partitiontest to tests. #3658

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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