Skip to content

Commit

Permalink
Merge branch 'beta' into fix-verifyMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeR26 authored Jan 16, 2024
2 parents 05f4095 + 0f8b266 commit ae49d2c
Show file tree
Hide file tree
Showing 35 changed files with 371 additions and 1,228 deletions.
13 changes: 2 additions & 11 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ name: _ Run Tests
on:
workflow_call:
inputs:
use-rpc-devnet:
type: boolean
default: false
use-seq-devnet:
use-devnet:
type: boolean
default: false
secrets:
TEST_PROVIDER_BASE_URL:
required: false
TEST_RPC_URL:
required: false
TEST_ACCOUNT_PRIVATE_KEY:
Expand All @@ -26,20 +21,16 @@ jobs:
# TODO - periodically check if conditional services are supported; https://github.com/actions/runner/issues/822
services:
devnet:
image: ${{ inputs.use-rpc-devnet && 'shardlabs/starknet-devnet-rs:0c82d023f35bb77c4b5f4afd885ab14e44b73130-amd-seed0' || inputs.use-seq-devnet && 'shardlabs/starknet-devnet:0.6.3-seed0' || '' }}
# image: ${{ (inputs.use-rpc-devnet || inputs.use-seq-devnet) && 'shardlabs/starknet-devnet:0.6.3-seed0' || '' }}
# image: shardlabs/starknet-devnet-rs:0c82d023f35bb77c4b5f4afd885ab14e44b73130-amd-seed0
image: ${{ (inputs.use-devnet) && 'shardlabs/starknet-devnet-rs:85495efb71a37ad3921c8986474b7e78a9a9f5fc-amd-seed0' || '' }}
ports:
- 5050:5050

env:
TEST_PROVIDER_BASE_URL: ${{ secrets.TEST_PROVIDER_BASE_URL }}
TEST_RPC_URL: ${{ secrets.TEST_RPC_URL }}
TEST_ACCOUNT_PRIVATE_KEY: ${{ secrets.TEST_ACCOUNT_PRIVATE_KEY }}
TEST_ACCOUNT_ADDRESS: ${{ secrets.TEST_ACCOUNT_ADDRESS }}

steps:
- run: echo ${{ secrets.TEST_PROVIDER_BASE_URL }}
- run: echo ${{ secrets.TEST_RPC_URL }}
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/manual-tests-devnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@ jobs:
strategy:
fail-fast: false
matrix:
name: [sequencer-devnet, rpc-devnet]
include:
- name: sequencer-devnet
TEST_PROVIDER_BASE_URL: http://127.0.0.1:5050/
- name: rpc-devnet
TEST_RPC_URL: http://127.0.0.1:5050/rpc

uses: ./.github/workflows/_test.yml
with:
use-rpc-devnet: ${{ matrix.TEST_RPC_URL != '' }}
use-seq-devnet: ${{ matrix.TEST_PROVIDER_BASE_URL != '' }}
use-devnet: ${{ matrix.TEST_RPC_URL != '' }}
secrets:
TEST_PROVIDER_BASE_URL: ${{ matrix.TEST_PROVIDER_BASE_URL }}
TEST_RPC_URL: ${{ matrix.TEST_RPC_URL }}
14 changes: 3 additions & 11 deletions .github/workflows/manual-tests-testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@ jobs:
tests:
name: Run test on ${{ matrix.name }}
strategy:
max-parallel: 1 # needed until we get a seperate account for the rpc provider, until then running them in parallel would result in a nonce issue
max-parallel: 1
matrix:
name: [sequencer-goerli, rpc-goerli]
include:
- name: sequencer-goerli
ENABLE_SEQUENCER: true
ENABLE_RPC: false
- name: rpc-goerli
ENABLE_SEQUENCER: false
ENABLE_RPC: true
name: [rpc-goerli]

uses: ./.github/workflows/_test.yml
secrets:
TEST_PROVIDER_BASE_URL: ${{ matrix.ENABLE_SEQUENCER && secrets.TEST_PROVIDER_BASE_URL || ''}}
TEST_RPC_URL: ${{ matrix.ENABLE_RPC && secrets.TEST_RPC_URL || ''}}
TEST_RPC_URL: ${{ secrets.TEST_RPC_URL }}
TEST_ACCOUNT_PRIVATE_KEY: ${{ secrets.TEST_ACCOUNT_PRIVATE_KEY }}
TEST_ACCOUNT_ADDRESS: ${{ secrets.TEST_ACCOUNT_ADDRESS }}
7 changes: 1 addition & 6 deletions .github/workflows/pr-push-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,14 @@ jobs:
strategy:
fail-fast: false
matrix:
name: [sequencer-devnet, rpc-devnet]
include:
- name: sequencer-devnet
TEST_PROVIDER_BASE_URL: http://127.0.0.1:5050/
- name: rpc-devnet
TEST_RPC_URL: http://127.0.0.1:5050/rpc

uses: ./.github/workflows/_test.yml
with:
use-rpc-devnet: ${{ matrix.TEST_RPC_URL != '' }}
use-seq-devnet: ${{ matrix.TEST_PROVIDER_BASE_URL != '' }}
use-devnet: ${{ matrix.TEST_RPC_URL != '' }}
secrets:
TEST_PROVIDER_BASE_URL: ${{ matrix.TEST_PROVIDER_BASE_URL }}
TEST_RPC_URL: ${{ matrix.TEST_RPC_URL }}

release:
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/pr-push-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,13 @@ jobs:
needs: [skip_check]
if: needs.skip_check.outputs.should_skip != 'true'
strategy:
max-parallel: 1 # needed until we get a seperate account for the rpc provider, until then running them in parallel would result in a nonce issue
max-parallel: 1
matrix:
name: [sequencer-goerli, rpc-goerli]
include:
- name: sequencer-goerli
ENABLE_SEQUENCER: true
ENABLE_RPC: false
- name: rpc-goerli
ENABLE_SEQUENCER: false
ENABLE_RPC: true
name: [rpc-goerli]

uses: ./.github/workflows/_test.yml
secrets:
TEST_PROVIDER_BASE_URL: ${{ matrix.ENABLE_SEQUENCER && secrets.TEST_PROVIDER_BASE_URL || ''}}
TEST_RPC_URL: ${{ matrix.ENABLE_RPC && secrets.TEST_RPC_URL || ''}}
TEST_RPC_URL: ${{ secrets.TEST_RPC_URL }}
TEST_ACCOUNT_PRIVATE_KEY: ${{ secrets.TEST_ACCOUNT_PRIVATE_KEY }}
TEST_ACCOUNT_ADDRESS: ${{ secrets.TEST_ACCOUNT_ADDRESS }}

Expand Down
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
# [6.0.0-beta.11](https://github.com/starknet-io/starknet.js/compare/v6.0.0-beta.10...v6.0.0-beta.11) (2024-01-04)

### Bug Fixes

- utilize provided resourceBounds value ([65bea53](https://github.com/starknet-io/starknet.js/commit/65bea53ab03a04fdd4c122ba2fecbb1010100e18))

# [6.0.0-beta.10](https://github.com/starknet-io/starknet.js/compare/v6.0.0-beta.9...v6.0.0-beta.10) (2023-12-20)

### Features

- req id counter ([cedd1ea](https://github.com/starknet-io/starknet.js/commit/cedd1ea32cd58107c504d357a3dd5e9a40010a80))

# [6.0.0-beta.9](https://github.com/starknet-io/starknet.js/compare/v6.0.0-beta.8...v6.0.0-beta.9) (2023-12-19)

### Bug Fixes

- acc deploy_acc ([732cd94](https://github.com/starknet-io/starknet.js/commit/732cd946f26c2b0fe893067f25c1fe712d72d49b))

# [6.0.0-beta.8](https://github.com/starknet-io/starknet.js/compare/v6.0.0-beta.7...v6.0.0-beta.8) (2023-12-19)

### Bug Fixes

- estimateFeeBulk provided version ([da717be](https://github.com/starknet-io/starknet.js/commit/da717be8e656087eaba21c865a6dd0b648664491))

# [6.0.0-beta.7](https://github.com/starknet-io/starknet.js/compare/v6.0.0-beta.6...v6.0.0-beta.7) (2023-12-14)

### Bug Fixes

- provider rpc 0.5-0.6 getTransactionReceipt response standardization ([76b6ab4](https://github.com/starknet-io/starknet.js/commit/76b6ab49f6721d1f76c3f30d3d88d6dbc8b80bda))

### Features

- curves ([405de46](https://github.com/starknet-io/starknet.js/commit/405de462032579ef0e8e434c62976dcb84ee1af8))
- **provider:** fix and clean provider response and response parser, removed seqeuncer api ([7ecb069](https://github.com/starknet-io/starknet.js/commit/7ecb069e3d2c37653cedc44dfbb635c5bc8eec7f))
- **provider:** pending response discrimination, pending type guards ([013a22b](https://github.com/starknet-io/starknet.js/commit/013a22bf4dd8cb6df817ccf6ff2d82837fe91693))

# [6.0.0-beta.6](https://github.com/starknet-io/starknet.js/compare/v6.0.0-beta.5...v6.0.0-beta.6) (2023-12-11)

### Features
Expand Down
4 changes: 3 additions & 1 deletion __tests__/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ describe('deploy and test Wallet', () => {
});

expect(result).toMatchSchemaRef('EstimateFee');
expect(innerInvokeEstFeeSpy.mock.calls[0][1].version).toBe(constants.TRANSACTION_VERSION.F1);
expect([constants.TRANSACTION_VERSION.F1, constants.TRANSACTION_VERSION.F3]).toContain(
innerInvokeEstFeeSpy.mock.calls[0][1].version
);
innerInvokeEstFeeSpy.mockClear();
});

Expand Down
5 changes: 3 additions & 2 deletions __tests__/config/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ if (process.env.DEBUG === 'true') {

response(response) {
const cloned = response.clone();
cloned.json().then(({ result }) => {
const match: any = combiner.find((it: any) => typeof it.result === 'undefined');
cloned.json().then((res) => {
const { result } = res;
const match: any = combiner.find((it: any) => it.request.body.id === res.id);
if (match && 'request' in match) {
match.result = result;
console.log(util.inspect(match, false, null, true /* enable colors */));
Expand Down
16 changes: 7 additions & 9 deletions __tests__/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {
BigNumberish,
Contract,
ContractFactory,
GetTransactionReceiptResponse,
ParsedEvents,
RawArgs,
SuccessfulTransactionReceiptResponse,
json,
stark,
} from '../src';
Expand Down Expand Up @@ -720,7 +720,7 @@ describe('Complex interaction', () => {
test('invoke compiled data', async () => {
const result = await erc20Echo20Contract.iecho(CallData.compile(request));
const transaction = await provider.waitForTransaction(result.transaction_hash);
expect((transaction as SuccessfulTransactionReceiptResponse).execution_status).toBeDefined();
expect((transaction as GetTransactionReceiptResponse).execution_status).toBeDefined();
});

// skip on live for performance
Expand All @@ -730,19 +730,19 @@ describe('Complex interaction', () => {

const result = await erc20Echo20Contract.iecho(calldata);
const transaction = await provider.waitForTransaction(result.transaction_hash);
expect((transaction as SuccessfulTransactionReceiptResponse).execution_status).toBeDefined();
expect((transaction as GetTransactionReceiptResponse).execution_status).toBeDefined();

const result1 = await erc20Echo20Contract.iecho(...args);
const transaction1 = await provider.waitForTransaction(result1.transaction_hash);
expect((transaction1 as SuccessfulTransactionReceiptResponse).execution_status).toBeDefined();
expect((transaction1 as GetTransactionReceiptResponse).execution_status).toBeDefined();

const result2 = await erc20Echo20Contract.invoke('iecho', calldata);
const transaction2 = await provider.waitForTransaction(result2.transaction_hash);
expect((transaction2 as SuccessfulTransactionReceiptResponse).execution_status).toBeDefined();
expect((transaction2 as GetTransactionReceiptResponse).execution_status).toBeDefined();

const result3 = await erc20Echo20Contract.invoke('iecho', args);
const transaction3 = await provider.waitForTransaction(result3.transaction_hash);
expect((transaction3 as SuccessfulTransactionReceiptResponse).execution_status).toBeDefined();
expect((transaction3 as GetTransactionReceiptResponse).execution_status).toBeDefined();
});

describe('speedup live tests', () => {
Expand Down Expand Up @@ -795,9 +795,7 @@ describe('Complex interaction', () => {
{ formatResponse }
);
const transaction = await provider.waitForTransaction(result.transaction_hash);
expect(
(transaction as SuccessfulTransactionReceiptResponse).execution_status
).toBeDefined();
expect((transaction as GetTransactionReceiptResponse).execution_status).toBeDefined();
});
});

Expand Down
36 changes: 13 additions & 23 deletions __tests__/defaultProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
} from './config/fixtures';
import { initializeMatcher } from './config/schema';

const { isPendingStateUpdate } = provider;

const testProvider = new Provider(getTestProvider());

describe('defaultProvider', () => {
Expand Down Expand Up @@ -81,32 +83,20 @@ describe('defaultProvider', () => {

test(`getStateUpdate(blockHash=${exampleBlockHash}, blockNumber=undefined)`, async () => {
const stateUpdate = await testProvider.getStateUpdate(exampleBlockHash);
provider.defStateUpdate(
stateUpdate,
(state) => {
expect(state.block_hash).toBe(exampleBlockHash);
expect(state).toMatchSchemaRef('StateUpdateResponse');
},
(pending) => {
fail('exampleBlockHash is latest block, should not be pending');
expect(pending).toMatchSchemaRef('PendingStateUpdateResponse');
}
);
if (isPendingStateUpdate(stateUpdate)) {
fail('exampleBlockHash is latest block, should not be pending');
}
expect(stateUpdate.block_hash).toBe(exampleBlockHash);
expect(stateUpdate).toMatchSchemaRef('StateUpdateResponse');
});

test(`getStateUpdate(blockHash=undefined, blockNumber=${exampleBlockNumber})`, async () => {
const stateUpdate = await testProvider.getStateUpdate(exampleBlockNumber);
provider.defStateUpdate(
stateUpdate,
(state) => {
expect(state.block_hash).toBe(exampleBlockHash);
expect(state).toMatchSchemaRef('StateUpdateResponse');
},
(pending) => {
fail('exampleBlockHash is latest block, should not be pending');
expect(pending).toMatchSchemaRef('PendingStateUpdateResponse');
}
);
if (isPendingStateUpdate(stateUpdate)) {
fail('exampleBlockHash is latest block, should not be pending');
}
expect(stateUpdate.block_hash).toBe(exampleBlockHash);
expect(stateUpdate).toMatchSchemaRef('StateUpdateResponse');
});
});

Expand Down Expand Up @@ -181,7 +171,7 @@ describe('defaultProvider', () => {
}),
})
.then((res) => {
expect(Array.isArray(res.result)).toBe(true);
expect(Array.isArray(res)).toBe(true);
})
).resolves.not.toThrow();
});
Expand Down
14 changes: 4 additions & 10 deletions __tests__/rpcProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { getStarkKey, utils } from '@scure/starknet';

import {
Account,
Block,
CallData,
Contract,
GetBlockResponse,
RPC,
TransactionExecutionStatus,
stark,
Expand Down Expand Up @@ -77,12 +77,6 @@ describeIfRpc('RPCProvider', () => {
expect(typeof spec).toBe('string');
});

test('getCode - not implemented', async () => {
expect(
rpcProvider.getCode('0x058d97f7d76e78f44905cc30cb65b91ea49a4b908a76703c54197bca90f81773')
).rejects.toThrow();
});

describe('Test Estimate message fee', () => {
const L1_ADDRESS = '0x8359E4B0152ed5A731162D3c7B0D8D56edB165A0';
let l1l2ContractAddress: string;
Expand Down Expand Up @@ -113,8 +107,8 @@ describeIfRpc('RPCProvider', () => {

describe('waitForTransaction', () => {
const receipt = {};
const transactionStatusSpy = jest.spyOn(rpcProvider as any, 'getTransactionStatus');
const transactionReceiptSpy = jest.spyOn(rpcProvider as any, 'getTransactionReceipt');
const transactionStatusSpy = jest.spyOn(rpcProvider.channel as any, 'getTransactionStatus');
const transactionReceiptSpy = jest.spyOn(rpcProvider.channel as any, 'getTransactionReceipt');

const generateOptions = (o: waitForTransactionOptions) => ({ retryInterval: 10, ...o });
const generateTransactionStatus = (
Expand Down Expand Up @@ -172,7 +166,7 @@ describeIfRpc('RPCProvider', () => {
});

describe('RPC methods', () => {
let latestBlock: GetBlockResponse;
let latestBlock: Block;

beforeAll(async () => {
latestBlock = await provider.getBlock('latest');
Expand Down
11 changes: 10 additions & 1 deletion __tests__/schemas/provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,16 @@
]
},
"actual_fee": {
"type": "string"
"type": "object",
"properties": {
"amount": {
"type": "string"
},
"unit": {
"type": "string",
"enum": ["WEI", "FRI"]
}
}
},
"status_data": {
"type": "string"
Expand Down
Loading

0 comments on commit ae49d2c

Please sign in to comment.