mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-06 01:32:18 +00:00
211d9bc0b9
* fix build from source * clean up * update again * change everything * workaround for now * fix versioning * all passing now * fix build issues * clean up * revert use of MulVerify * gaz * stub * Apply suggestions from code review Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * fix all * fix test * todo * fix stub * revert back * make deep source happy * Update shared/bls/herumi/public_key.go * Update shared/bls/blst/signature.go * Update shared/bls/blst/signature_test.go * imports * move iface to common, export errors * rm iface build Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> Co-authored-by: terence tsao <terence@prysmaticlabs.com>
65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
package spectest
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"path"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/ghodss/yaml"
|
|
"github.com/prysmaticlabs/prysm/shared/bls"
|
|
"github.com/prysmaticlabs/prysm/shared/bls/common"
|
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
)
|
|
|
|
func TestAggregateYaml(t *testing.T) {
|
|
flags := &featureconfig.Flags{}
|
|
reset := featureconfig.InitWithReset(flags)
|
|
t.Run("herumi", testAggregateYaml)
|
|
reset()
|
|
|
|
flags.EnableBlst = true
|
|
reset = featureconfig.InitWithReset(flags)
|
|
t.Run("blst", testAggregateYaml)
|
|
reset()
|
|
}
|
|
|
|
func testAggregateYaml(t *testing.T) {
|
|
testFolders, testFolderPath := testutil.TestFolders(t, "general", "bls/aggregate/small")
|
|
|
|
for _, folder := range testFolders {
|
|
t.Run(folder.Name(), func(t *testing.T) {
|
|
file, err := testutil.BazelFileBytes(path.Join(testFolderPath, folder.Name(), "data.yaml"))
|
|
require.NoError(t, err)
|
|
test := &AggregateTest{}
|
|
require.NoError(t, yaml.Unmarshal(file, test))
|
|
var sigs []common.Signature
|
|
for _, s := range test.Input {
|
|
sigBytes, err := hex.DecodeString(s[2:])
|
|
require.NoError(t, err)
|
|
sig, err := bls.SignatureFromBytes(sigBytes)
|
|
require.NoError(t, err)
|
|
sigs = append(sigs, sig)
|
|
}
|
|
if len(test.Input) == 0 {
|
|
if test.Output != "" {
|
|
t.Fatalf("Output Aggregate is not of zero length:Output %s", test.Output)
|
|
}
|
|
return
|
|
}
|
|
sig := bls.AggregateSignatures(sigs)
|
|
if strings.Contains(folder.Name(), "aggregate_na_pubkeys") {
|
|
if sig != nil {
|
|
t.Errorf("Expected nil signature, received: %v", sig)
|
|
}
|
|
return
|
|
}
|
|
outputBytes, err := hex.DecodeString(test.Output[2:])
|
|
require.NoError(t, err)
|
|
require.DeepEqual(t, outputBytes, sig.Marshal())
|
|
})
|
|
}
|
|
}
|