update tests
This commit is contained in:
parent
114a344fb6
commit
20121c330b
|
@ -47,7 +47,7 @@ export function sign(secretKey: Uint8Array, messageHash: Uint8Array): Buffer {
|
|||
* @param signatures
|
||||
*/
|
||||
export function aggregateSignatures(signatures: Uint8Array[]): Buffer {
|
||||
assert(signatures, "signatures is null or undefined");
|
||||
assert(signatures && signatures.length > 0, "signatures is null or undefined or empty array");
|
||||
return Signature.aggregate(
|
||||
signatures.map((signature): Signature => {
|
||||
return Signature.fromCompressedBytes(signature);
|
||||
|
|
|
@ -20,10 +20,17 @@ describeDirectorySpecTest<IAggregateSigsTestCase, string>(
|
|||
"../../node_modules/@chainsafe/eth2-spec-tests/tests/general/phase0/bls/aggregate/small"
|
||||
),
|
||||
(testCase => {
|
||||
const result = bls.aggregateSignatures(testCase.data.input.map(pubKey => {
|
||||
return Buffer.from(pubKey.replace("0x", ""), "hex");
|
||||
}));
|
||||
return `0x${result.toString("hex")}`;
|
||||
try {
|
||||
const result = bls.aggregateSignatures(testCase.data.input.map(pubKey => {
|
||||
return Buffer.from(pubKey.replace("0x", ""), "hex");
|
||||
}));
|
||||
return `0x${result.toString("hex")}`;
|
||||
} catch (e) {
|
||||
if(e.message === "signatures is null or undefined or empty array") {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}),
|
||||
{
|
||||
inputTypes: {
|
||||
|
|
|
@ -5,10 +5,8 @@ import {describeDirectorySpecTest, InputType} from "@chainsafe/lodestar-spec-tes
|
|||
interface AggregateSigsVerifyTestCase {
|
||||
data: {
|
||||
input: {
|
||||
pairs: [{
|
||||
pubkey: string;
|
||||
message: string;
|
||||
}];
|
||||
pubkeys: string[];
|
||||
messages: string[];
|
||||
signature: string;
|
||||
};
|
||||
output: boolean;
|
||||
|
@ -30,11 +28,11 @@ describeDirectorySpecTest<AggregateSigsVerifyTestCase, boolean>(
|
|||
"../../node_modules/@chainsafe/eth2-spec-tests/tests/general/phase0/bls/aggregate_verify/small"
|
||||
),
|
||||
(testCase => {
|
||||
const pubkeys = testCase.data.input.pairs.map(pair => {
|
||||
return Buffer.from(pair.pubkey.replace("0x", ""), "hex");
|
||||
const pubkeys = testCase.data.input.pubkeys.map(pubkey => {
|
||||
return Buffer.from(pubkey.replace("0x", ""), "hex");
|
||||
});
|
||||
const messages = testCase.data.input.pairs.map(pair => {
|
||||
return Buffer.from(pair.message.replace("0x", ""), "hex");
|
||||
const messages = testCase.data.input.messages.map(msg => {
|
||||
return Buffer.from(msg.replace("0x", ""), "hex");
|
||||
});
|
||||
return bls.verifyMultiple(
|
||||
pubkeys,
|
||||
|
|
Reference in New Issue