-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: replace docker-based inscription builder sidecar with Golan…
…g implementation (#3082) * initiate bitcoin inscription builder using golang * use the tokenizer in the upgraded btcd package * add changelog entry * fix CI unit test failure * replace 80 with btcd defined constant; update comments * replace hardcoded number with btcd defined constant * fix coderabbit comment and tidy go mod * remove randomness in E2E fee estimation
- Loading branch information
1 parent
b317941
commit 7474ab5
Showing
15 changed files
with
304 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
e2e/e2etests/test_bitcoin_std_memo_inscribed_deposit_and_call.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package e2etests | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/zeta-chain/node/e2e/runner" | ||
"github.com/zeta-chain/node/e2e/utils" | ||
"github.com/zeta-chain/node/pkg/memo" | ||
testcontract "github.com/zeta-chain/node/testutil/contracts" | ||
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" | ||
zetabitcoin "github.com/zeta-chain/node/zetaclient/chains/bitcoin" | ||
) | ||
|
||
func TestBitcoinStdMemoInscribedDepositAndCall(r *runner.E2ERunner, args []string) { | ||
// ARRANGE | ||
// Given BTC address | ||
r.SetBtcAddress(r.Name, false) | ||
|
||
// Start mining blocks | ||
stop := r.MineBlocksIfLocalBitcoin() | ||
defer stop() | ||
|
||
// Given amount to send and fee rate | ||
require.Len(r, args, 2) | ||
amount := parseFloat(r, args[0]) | ||
feeRate := parseInt(r, args[1]) | ||
|
||
// deploy an example contract in ZEVM | ||
contractAddr, _, contract, err := testcontract.DeployExample(r.ZEVMAuth, r.ZEVMClient) | ||
require.NoError(r, err) | ||
|
||
// create a standard memo > 80 bytes | ||
memo := &memo.InboundMemo{ | ||
Header: memo.Header{ | ||
Version: 0, | ||
EncodingFmt: memo.EncodingFmtCompactShort, | ||
OpCode: memo.OpCodeDepositAndCall, | ||
}, | ||
FieldsV0: memo.FieldsV0{ | ||
Receiver: contractAddr, | ||
Payload: []byte("for use case that passes a large memo > 80 bytes, inscripting the memo is the way to go"), | ||
}, | ||
} | ||
memoBytes, err := memo.EncodeToBytes() | ||
require.NoError(r, err) | ||
|
||
// ACT | ||
// Send BTC to TSS address with memo | ||
txHash, depositAmount := r.InscribeToTSSFromDeployerWithMemo(amount, memoBytes, int64(feeRate)) | ||
|
||
// ASSERT | ||
// wait for the cctx to be mined | ||
cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, txHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) | ||
r.Logger.CCTX(*cctx, "bitcoin_std_memo_inscribed_deposit_and_call") | ||
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined) | ||
|
||
// check if example contract has been called, 'bar' value should be set to correct amount | ||
depositFeeSats, err := zetabitcoin.GetSatoshis(zetabitcoin.DefaultDepositorFee) | ||
require.NoError(r, err) | ||
receiveAmount := depositAmount - depositFeeSats | ||
utils.MustHaveCalledExampleContract(r, contract, big.NewInt(receiveAmount)) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.