Add basic system-program tests
This commit is contained in:
@ -15,7 +15,6 @@ test('pay', () => {
|
|||||||
to.publicKey,
|
to.publicKey,
|
||||||
123,
|
123,
|
||||||
);
|
);
|
||||||
console.log('Pay:', transaction);
|
|
||||||
expect(transaction.keys).toHaveLength(2);
|
expect(transaction.keys).toHaveLength(2);
|
||||||
// TODO: Validate transaction contents more
|
// TODO: Validate transaction contents more
|
||||||
|
|
||||||
@ -26,7 +25,6 @@ test('pay', () => {
|
|||||||
123,
|
123,
|
||||||
BudgetProgram.signatureCondition(from.publicKey),
|
BudgetProgram.signatureCondition(from.publicKey),
|
||||||
);
|
);
|
||||||
console.log('After:', transaction);
|
|
||||||
expect(transaction.keys).toHaveLength(3);
|
expect(transaction.keys).toHaveLength(3);
|
||||||
// TODO: Validate transaction contents more
|
// TODO: Validate transaction contents more
|
||||||
|
|
||||||
@ -38,7 +36,6 @@ test('pay', () => {
|
|||||||
BudgetProgram.signatureCondition(from.publicKey),
|
BudgetProgram.signatureCondition(from.publicKey),
|
||||||
BudgetProgram.timestampCondition(from.publicKey, new Date()),
|
BudgetProgram.timestampCondition(from.publicKey, new Date()),
|
||||||
);
|
);
|
||||||
console.log('Or:', transaction);
|
|
||||||
expect(transaction.keys).toHaveLength(3);
|
expect(transaction.keys).toHaveLength(3);
|
||||||
// TODO: Validate transaction contents more
|
// TODO: Validate transaction contents more
|
||||||
});
|
});
|
||||||
@ -55,7 +52,6 @@ test('apply', () => {
|
|||||||
to.publicKey,
|
to.publicKey,
|
||||||
new Date(),
|
new Date(),
|
||||||
);
|
);
|
||||||
console.log('applyTimestamp:', transaction);
|
|
||||||
expect(transaction.keys).toHaveLength(3);
|
expect(transaction.keys).toHaveLength(3);
|
||||||
// TODO: Validate transaction contents more
|
// TODO: Validate transaction contents more
|
||||||
|
|
||||||
@ -64,7 +60,6 @@ test('apply', () => {
|
|||||||
program.publicKey,
|
program.publicKey,
|
||||||
to.publicKey,
|
to.publicKey,
|
||||||
);
|
);
|
||||||
console.log('applySignature:', transaction);
|
|
||||||
expect(transaction.keys).toHaveLength(3);
|
expect(transaction.keys).toHaveLength(3);
|
||||||
// TODO: Validate transaction contents more
|
// TODO: Validate transaction contents more
|
||||||
});
|
});
|
||||||
|
55
web3.js/test/system-program.test.js
Normal file
55
web3.js/test/system-program.test.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// @flow
|
||||||
|
|
||||||
|
import {Account, SystemProgram, BudgetProgram} from '../src';
|
||||||
|
|
||||||
|
test('createAccount', () => {
|
||||||
|
const from = new Account();
|
||||||
|
const newAccount = new Account();
|
||||||
|
let transaction;
|
||||||
|
|
||||||
|
transaction = SystemProgram.createAccount(
|
||||||
|
from.publicKey,
|
||||||
|
newAccount.publicKey,
|
||||||
|
123,
|
||||||
|
BudgetProgram.space,
|
||||||
|
BudgetProgram.programId,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(transaction.keys).toHaveLength(2);
|
||||||
|
expect(transaction.programId).toEqual(SystemProgram.programId);
|
||||||
|
// TODO: Validate transaction contents more
|
||||||
|
});
|
||||||
|
|
||||||
|
test('move', () => {
|
||||||
|
const from = new Account();
|
||||||
|
const to = new Account();
|
||||||
|
let transaction;
|
||||||
|
|
||||||
|
transaction = SystemProgram.move(
|
||||||
|
from.publicKey,
|
||||||
|
to.publicKey,
|
||||||
|
123,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(transaction.keys).toHaveLength(2);
|
||||||
|
expect(transaction.programId).toEqual(SystemProgram.programId);
|
||||||
|
// TODO: Validate transaction contents more
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
test('assign', () => {
|
||||||
|
const from = new Account();
|
||||||
|
const to = new Account();
|
||||||
|
let transaction;
|
||||||
|
|
||||||
|
transaction = SystemProgram.assign(
|
||||||
|
from.publicKey,
|
||||||
|
to.publicKey,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(transaction.keys).toHaveLength(1);
|
||||||
|
expect(transaction.programId).toEqual(SystemProgram.programId);
|
||||||
|
// TODO: Validate transaction contents more
|
||||||
|
});
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user