Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unit test for KMS is not correct #1779

Open
victhorbi opened this issue Jan 31, 2025 · 1 comment
Open

[BUG] Unit test for KMS is not correct #1779

victhorbi opened this issue Jan 31, 2025 · 1 comment
Assignees
Milestone

Comments

@victhorbi
Copy link
Collaborator

Also, unit test for KMS is not correct:

            ({ description, isDelegated, expected }) => {
                test(
                    description,
                    async () => {
                        const signTransactionSigner = isDelegated
                            ? signerWithDelegator
                            : signer;
                        const sampleClause = Clause.callFunction(
                            Address.of(TESTING_CONTRACT_ADDRESS),
                            ABIContract.ofAbi(TESTING_CONTRACT_ABI).getFunction(
                                'deposit'
                            ),
                            [123]
                        ) as TransactionClause;

                        const originAddress =
                            await signTransactionSigner.getAddress();

                        const gasResult = await thorClient.gas.estimateGas(
                            [sampleClause],
                            originAddress
                        );

                        const txBody =
                            await thorClient.transactions.buildTransactionBody(
                                [sampleClause],
                                gasResult.totalGas,
                                {
                                    isDelegated
                                }
                            );

                        const signedRawTx =
                            await signTransactionSigner.signTransaction(
                                signerUtils.transactionBodyToTransactionRequestInput(
                                    txBody,
                                    originAddress
                                )
                            );
                        const signedTx = Transaction.decode(
                            HexUInt.of(signedRawTx.slice(2)).bytes,
                            true
                        );

                        expect(signedTx).toBeDefined();
                        expect(signedTx.body).toMatchObject(expected.body);
                        expect(signedTx.origin.toString()).toBe(
                            Address.checksum(HexUInt.of(originAddress))
                        );
                        expect(signedTx.isDelegated).toBe(isDelegated);
                        expect(signedTx.isSigned).toBe(true);
                        expect(signedTx.signature).toBeDefined();
                    },
                    timeout
                );

As we see, unit test signs transaction both for gasPayer and as origin. That goes agains VIP-191.

https://github.com/vechain/VIPs/blob/master/vips/VIP-191.md

Originally posted by @iggyzap in #1775

@victhorbi
Copy link
Collaborator Author

@GrandinLuc

Is this still open?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants