fix: correctly count duplicate signing keys
This commit is contained in:
parent
48f0bcc2bf
commit
f7a02e54df
@ -163,10 +163,10 @@ export class Transaction {
|
|||||||
|
|
||||||
instruction.keys.forEach(keySignerPair => {
|
instruction.keys.forEach(keySignerPair => {
|
||||||
const keyStr = keySignerPair.pubkey.toString();
|
const keyStr = keySignerPair.pubkey.toString();
|
||||||
if (keySignerPair.isSigner) {
|
|
||||||
numRequiredSignatures += 1;
|
|
||||||
}
|
|
||||||
if (!keys.includes(keyStr)) {
|
if (!keys.includes(keyStr)) {
|
||||||
|
if (keySignerPair.isSigner) {
|
||||||
|
numRequiredSignatures += 1;
|
||||||
|
}
|
||||||
keys.push(keyStr);
|
keys.push(keyStr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -56,6 +56,28 @@ test('transfer signatures', () => {
|
|||||||
expect(newTransaction).toEqual(orgTransaction);
|
expect(newTransaction).toEqual(orgTransaction);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('dedup signatures', () => {
|
||||||
|
const account1 = new Account();
|
||||||
|
const account2 = new Account();
|
||||||
|
const recentBlockhash = account1.publicKey.toBase58(); // Fake recentBlockhash
|
||||||
|
const transfer1 = SystemProgram.transfer(
|
||||||
|
account1.publicKey,
|
||||||
|
account2.publicKey,
|
||||||
|
123,
|
||||||
|
);
|
||||||
|
const transfer2 = SystemProgram.transfer(
|
||||||
|
account1.publicKey,
|
||||||
|
account2.publicKey,
|
||||||
|
123,
|
||||||
|
);
|
||||||
|
|
||||||
|
const orgTransaction = new Transaction({recentBlockhash}).add(
|
||||||
|
transfer1,
|
||||||
|
transfer2,
|
||||||
|
);
|
||||||
|
orgTransaction.sign(account1);
|
||||||
|
});
|
||||||
|
|
||||||
test('parse wire format and serialize', () => {
|
test('parse wire format and serialize', () => {
|
||||||
const keypair = nacl.sign.keyPair.fromSeed(
|
const keypair = nacl.sign.keyPair.fromSeed(
|
||||||
Uint8Array.from(Array(32).fill(8)),
|
Uint8Array.from(Array(32).fill(8)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user