Compare commits
No commits in common. "d256fcb35d03593996e2455a4db9d546d4d27274" and "d169ff34a56c069c2b5a15a53c9e0acee458281b" have entirely different histories.
d256fcb35d
...
d169ff34a5
|
@ -1,5 +0,0 @@
|
||||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
||||||
module.exports = {
|
|
||||||
preset: 'ts-jest',
|
|
||||||
testEnvironment: 'node',
|
|
||||||
};
|
|
|
@ -9,8 +9,6 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.1.0",
|
"@types/node": "^20.1.0",
|
||||||
"jest": "^29.5.0",
|
|
||||||
"ts-jest": "^29.1.0",
|
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "^5.0.4"
|
"typescript": "^5.0.4"
|
||||||
},
|
},
|
||||||
|
|
47
ws.test.ts
47
ws.test.ts
|
@ -1,47 +0,0 @@
|
||||||
import { Connection, Keypair, sendAndConfirmTransaction, Transaction, PublicKey, TransactionInstruction, BlockheightBasedTransactionConfirmationStrategy } from "@solana/web3.js";
|
|
||||||
import * as fs from "fs";
|
|
||||||
import * as os from "os";
|
|
||||||
import * as crypto from "crypto";
|
|
||||||
|
|
||||||
jest.setTimeout(60000);
|
|
||||||
|
|
||||||
const MEMO_PROGRAM_ID = new PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");
|
|
||||||
const connection = new Connection('http://0.0.0.0:8899', 'confirmed');
|
|
||||||
const keypair_file = fs.readFileSync(`${os.homedir}/.config/solana/id.json`, 'utf-8');
|
|
||||||
const payer = Keypair.fromSecretKey(Uint8Array.from(JSON.parse(keypair_file)));
|
|
||||||
|
|
||||||
function createTransaction(): Transaction {
|
|
||||||
const transaction = new Transaction();
|
|
||||||
|
|
||||||
transaction.add(
|
|
||||||
new TransactionInstruction({
|
|
||||||
programId: MEMO_PROGRAM_ID,
|
|
||||||
keys: [],
|
|
||||||
data: Buffer.from(crypto.randomBytes(20).toString('hex'))
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return transaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
test('send and confirm transaction BlockheightBasedTransactionConfirmationStrategy', async () => {
|
|
||||||
const tx = createTransaction();
|
|
||||||
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
||||||
|
|
||||||
const signature = await connection.sendTransaction(tx, [payer]);
|
|
||||||
await connection.confirmTransaction({
|
|
||||||
blockhash,
|
|
||||||
lastValidBlockHeight,
|
|
||||||
signature,
|
|
||||||
abortSignal: undefined
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(`https://explorer.solana.com/tx/${signature}`)
|
|
||||||
});
|
|
||||||
|
|
||||||
test('send and confirm transaction', async () => {
|
|
||||||
const tx = createTransaction();
|
|
||||||
|
|
||||||
await sendAndConfirmTransaction(connection, tx, [payer]);
|
|
||||||
});
|
|
||||||
|
|
Loading…
Reference in New Issue