Skip to content

Commit

Permalink
Merge branch 'feat/upd-47' into feat/contract-manager-resubmit
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverHappened committed Aug 22, 2023
2 parents 625b035 + f3cf947 commit 0b19e3f
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 14 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion setup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build-neutron:
cd $(APP_DIR)/neutron && $(MAKE) build-docker-image

build-hermes:
@docker build -f dockerbuilds/Dockerfile.hermes -t hermes:1.3.0-a285c01 .
@docker build -f dockerbuilds/Dockerfile.hermes -t hermes:1.6.0-1c1cf029 .

build-relayer:
cd $(APP_DIR)/neutron-query-relayer/ && make build-docker
Expand Down
2 changes: 1 addition & 1 deletion setup/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ services:
- neutron-testing

hermes:
image: hermes:1.3.0-a285c01
image: hermes:1.6.0-1c1cf029
depends_on:
- "neutron-node"
- "gaia-node"
Expand Down
2 changes: 1 addition & 1 deletion setup/dockerbuilds/Dockerfile.hermes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COPY ./hermes/ /app/network/hermes/
WORKDIR /app
RUN apt-get update && apt-get install -y wget && \
PLATFORM=`uname -a | awk '{print $(NF-1)}'` && \
VERSION=v1.4.0 && \
VERSION=v1.6.0 && \
TARNAME="hermes-${VERSION}-${PLATFORM}-unknown-linux-gnu.tar.gz" && \
wget "https://github.com/informalsystems/hermes/releases/download/${VERSION}/${TARNAME}" && \
tar -xf "$TARNAME" && \
Expand Down
15 changes: 11 additions & 4 deletions setup/hermes/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,42 +93,49 @@ port = 3001
id = 'test-1'
rpc_addr = 'http://neutron-node:26657'
grpc_addr = 'http://neutron-node:9090'
websocket_addr = 'ws://neutron-node:26657/websocket'
event_source = { mode = 'push', url = 'ws://neutron-node:26657/websocket', batch_delay = '200ms' }
ccv_consumer_chain = true
rpc_timeout = '10s'
account_prefix = 'neutron'
key_name = 'testkey_1'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 3000000
gas_price = { price = 0.0025, denom = 'untrn' }
<<<<<<< HEAD
gas_multiplier = 2.0
=======
gas_multiplier = 1.5
>>>>>>> main
max_msg_num = 30
max_tx_size = 2097152
clock_drift = '5s'
max_block_time = '10s'
trusting_period = '14days'
unbonding_period = '20days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'cosmos' }

[[chains]]
id = 'test-2'
rpc_addr = 'http://gaia-node:26657'
grpc_addr = 'http://gaia-node:9090'
websocket_addr = 'ws://gaia-node:26657/websocket'
event_source = { mode = 'push', url = 'ws://gaia-node:26657/websocket', batch_delay = '200ms' }
rpc_timeout = '10s'
account_prefix = 'cosmos'
key_name = 'testkey_2'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 3000000
gas_price = { price = 0.0025, denom = 'uatom' }
<<<<<<< HEAD
gas_multiplier = 2.0
=======
gas_multiplier = 1.5
>>>>>>> main
max_msg_num = 30
max_tx_size = 2097152
clock_drift = '5s'
max_block_time = '10s'
trusting_period = '14days'
unbonding_period = '21days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'cosmos' }
28 changes: 28 additions & 0 deletions src/helpers/cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,34 @@ export class WalletWrapper {
]);
}

async migrateContract(
contract: string,
codeId: number,
msg: string | Record<string, unknown>,
): Promise<BroadcastTx200ResponseTxResponse> {
const sender = this.wallet.address.toString();
const msgMigrate =
new cosmwasmclient.proto.cosmwasm.wasm.v1.MsgMigrateContract({
sender,
contract,
code_id: codeId + '',
msg: Buffer.from(typeof msg === 'string' ? msg : JSON.stringify(msg)),
});
const res = await this.execTx(
{
gas_limit: Long.fromString('5000000'),
amount: [{ denom: this.chain.denom, amount: '20000' }],
},
[msgMigrate],
);
if (res.tx_response.code !== 0) {
throw new Error(
`${res.tx_response.raw_log}\nFailed tx hash: ${res.tx_response.txhash}`,
);
}
return res?.tx_response;
}

async executeContract(
contract: string,
msg: string,
Expand Down
8 changes: 8 additions & 0 deletions src/testcases/parallel/stargate_queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,13 @@ describe('Neutron / Simple', () => {
const res = JSON.parse(await querySmart({ feeburner_params: {} }));
expect(res.params.neutron_denom).toBe('untrn');
});

test('non whitelisted query should NOT work', async () => {
await expect(
querySmart({ feeburner_total_burned_neutrons_amount: {} }),
).rejects.toThrow(
/Unsupported query type: '\/neutron.feeburner.Query\/TotalBurnedNeutronsAmount'/,
);
});
});
});
79 changes: 77 additions & 2 deletions src/testcases/run_in_band/interchaintx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('Neutron / Interchain TXs', () => {
validator: (
testState.wallets.cosmos.val1.address as cosmosclient.ValAddress
).toString(),
amount: '2000',
amount: '1000',
denom: gaiaChain.denom,
},
}),
Expand Down Expand Up @@ -208,6 +208,79 @@ describe('Neutron / Interchain TXs', () => {
async (delegations) =>
delegations.data.delegation_responses?.length == 1,
);
expect(res1.data.delegation_responses).toEqual([
{
balance: { amount: '1000', denom: gaiaChain.denom },
delegation: {
delegator_address: icaAddress1,
shares: '1000.000000000000000000',
validator_address:
'cosmosvaloper18hl5c9xn5dze2g50uaw0l2mr02ew57zk0auktn',
},
},
]);
const res2 = await cosmosclient.rest.staking.delegatorDelegations(
gaiaChain.sdk as CosmosSDK,
icaAddress2 as unknown as AccAddress,
);
expect(res2.data.delegation_responses).toEqual([]);
});
test('check contract balance', async () => {
const res = await neutronChain.queryBalances(contractAddress);
const balance = res.balances.find(
(b) => b.denom === neutronChain.denom,
)?.amount;
expect(balance).toEqual('98000');
});
});

describe('DOUBLE ACK - Send Interchain TX', () => {
test('delegate from first ICA', async () => {
// it will delegate two times of passed amount - first from contract call, and second from successful sudo IBC response
const res = await neutronAccount.executeContract(
contractAddress,
JSON.stringify({
delegate_double_ack: {
interchain_account_id: icaId1,
validator: (
testState.wallets.cosmos.val1.address as cosmosclient.ValAddress
).toString(),
amount: '500',
denom: gaiaChain.denom,
},
}),
);
expect(res.code).toEqual(0);
const sequenceId = getSequenceId(res.raw_log);

await waitForAck(neutronChain, contractAddress, icaId1, sequenceId);
const qres = await getAck(
neutronChain,
contractAddress,
icaId1,
sequenceId,
);
expect(qres).toMatchObject<AcknowledgementResult>({
success: ['/cosmos.staking.v1beta1.MsgDelegate'],
});

const ackSequenceId = sequenceId + 1;
await waitForAck(neutronChain, contractAddress, icaId1, ackSequenceId);
expect(qres).toMatchObject<AcknowledgementResult>({
success: ['/cosmos.staking.v1beta1.MsgDelegate'],
});
});
test('check validator state', async () => {
const res1 = await getWithAttempts(
gaiaChain.blockWaiter,
() =>
cosmosclient.rest.staking.delegatorDelegations(
gaiaChain.sdk as CosmosSDK,
icaAddress1 as unknown as AccAddress,
),
async (delegations) =>
delegations.data.delegation_responses?.length === 1,
);
expect(res1.data.delegation_responses).toEqual([
{
balance: { amount: '2000', denom: gaiaChain.denom },
Expand All @@ -230,9 +303,11 @@ describe('Neutron / Interchain TXs', () => {
const balance = res.balances.find(
(b) => b.denom === neutronChain.denom,
)?.amount;
expect(balance).toEqual('98000');
// two interchain txs inside (2000 * 2 = 4000)
expect(balance).toEqual('94000');
});
});

describe('Error cases', () => {
test('delegate for unknown validator from second ICA', async () => {
const res = await neutronAccount.executeContract(
Expand Down
Loading

0 comments on commit 0b19e3f

Please sign in to comment.