mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-06 01:32:18 +00:00
f61f02e59b
* cmd tests * deposit util tests * feature config tests * hashutil tests * htr util tests * interop tests * ip util tests * Update BLS * Update cmd * Update bytesutil and depositutil * Update event * Update keystore * Update mathutil * Update mputil * Update pagination * Update params * Upate prome * Update testutil * Update trieutil * Merge branch 'master' of github.com:prysmaticlabs/prysm into testutil-shared * Sync with master * Mod * Typo * Revert * gazelle * Merge refs/heads/master into testutil-shared * Merge refs/heads/master into testutil-shared * Merge refs/heads/master into testutil-shared * Merge refs/heads/master into testutil-shared * Gaz * Merge refs/heads/master into testutil-shared * Merge refs/heads/master into testutil-shared * Merge refs/heads/master into testutil-shared * Merge refs/heads/master into testutil-shared * Merge refs/heads/master into testutil-shared * Merge refs/heads/master into testutil-shared * Merge refs/heads/master into testutil-shared * fixes build error * Merge refs/heads/master into testutil-shared
52 lines
1.4 KiB
Go
52 lines
1.4 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/iface"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
)
|
|
|
|
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 []iface.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())
|
|
})
|
|
}
|
|
}
|