fix: allow messages to be compiled without instructions (#17621)

* fix: allow messages to be compiled without instructions

* chore: fix tests
This commit is contained in:
Justin Starry 2021-06-02 12:39:59 -07:00 committed by GitHub
parent 19c49e2e25
commit 3e13cde988
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 15 deletions

View File

@ -214,7 +214,7 @@ export class Transaction {
}
if (this.instructions.length < 1) {
throw new Error('No instructions provided');
console.warn('No instructions provided');
}
let feePayer: PublicKey;

View File

@ -65,9 +65,7 @@ describe('Transaction', () => {
it('validation', () => {
const payer = Keypair.generate();
const other = Keypair.generate();
const recentBlockhash = Keypair.generate().publicKey.toBase58();
const programId = Keypair.generate().publicKey;
const transaction = new Transaction();
expect(() => {
@ -76,18 +74,6 @@ describe('Transaction', () => {
transaction.recentBlockhash = recentBlockhash;
expect(() => {
transaction.compileMessage();
}).to.throw('No instructions provided');
transaction.add({
keys: [
{pubkey: other.publicKey, isSigner: true, isWritable: true},
{pubkey: payer.publicKey, isSigner: true, isWritable: true},
],
programId,
});
expect(() => {
transaction.compileMessage();
}).to.throw('Transaction fee payer required');