Skip to content

Commit

Permalink
feat: agave v2 rpc: replace getConfirmedBlock with getBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Dec 6, 2024
1 parent 6bbf467 commit 6607d91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5225,7 +5225,7 @@ export class Connection {
commitment?: Finality,
): Promise<ConfirmedBlock> {
const args = this._buildArgsAtLeastConfirmed([slot], commitment);
const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
const unsafeRes = await this._rpcRequest('getBlock', args);
const res = create(unsafeRes, GetConfirmedBlockRpcResult);

if ('error' in res) {
Expand Down Expand Up @@ -5331,7 +5331,7 @@ export class Connection {
rewards: false,
},
);
const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
const unsafeRes = await this._rpcRequest('getBlock', args);
const res = create(unsafeRes, GetBlockSignaturesRpcResult);
if ('error' in res) {
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
Expand Down
22 changes: 11 additions & 11 deletions test/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2351,7 +2351,7 @@ describe('Connection', function () {
await waitForSlot.call(this, connection, 1);

await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [1],
value: {
blockTime: 1614281964,
Expand Down Expand Up @@ -2433,7 +2433,7 @@ describe('Connection', function () {
const mockSignature =
'5SHZ9NwpnS9zYnauN7pnuborKf39zGMr11XpMC59VvRSeDJNcnYLecmdxXCVuBFPNQLdCBBjyZiNCL4KoHKr3tvz';
await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [slot, {transactionDetails: 'signatures', rewards: false}],
value: {
blockTime: 1614281964,
Expand All @@ -2449,7 +2449,7 @@ describe('Connection', function () {
value: 123,
});
await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [slot + 2, {transactionDetails: 'signatures', rewards: false}],
value: {
blockTime: 1614281964,
Expand Down Expand Up @@ -2482,7 +2482,7 @@ describe('Connection', function () {

const badSlot = Number.MAX_SAFE_INTEGER - 1;
await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [badSlot - 1, {transactionDetails: 'signatures', rewards: false}],
error: {message: 'Block not available for slot ' + badSlot},
});
Expand Down Expand Up @@ -2531,7 +2531,7 @@ describe('Connection', function () {
await waitForSlot.call(this, connection, 1);

await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [1],
value: {
blockTime: 1614281964,
Expand Down Expand Up @@ -2640,7 +2640,7 @@ describe('Connection', function () {
await waitForSlot.call(this, connection, 1);

await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [1],
value: {
blockTime: 1614281964,
Expand Down Expand Up @@ -3294,7 +3294,7 @@ describe('Connection', function () {
await waitForSlot.call(this, connection, 1);

await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [1],
value: {
blockTime: 1614281964,
Expand Down Expand Up @@ -4252,7 +4252,7 @@ describe('Connection', function () {

it('gets the genesis block', async function () {
await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [0],
value: {
blockHeight: 0,
Expand Down Expand Up @@ -4290,7 +4290,7 @@ describe('Connection', function () {
it('gets a block having a parent', async function () {
// Mock parent of block with transaction.
await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [0],
value: {
blockHeight: 0,
Expand All @@ -4303,7 +4303,7 @@ describe('Connection', function () {
});
// Mock block with transaction.
await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [1],
value: {
blockTime: 1614281964,
Expand Down Expand Up @@ -4390,7 +4390,7 @@ describe('Connection', function () {
.null;

await mockRpcResponse({
method: 'getConfirmedBlock',
method: 'getBlock',
params: [Number.MAX_SAFE_INTEGER],
error: {
message: `Block not available for slot ${Number.MAX_SAFE_INTEGER}`,
Expand Down

0 comments on commit 6607d91

Please sign in to comment.