massalabs / massa-test-framework

1 stars 0 forks source link

Rewrite the framework in TS #29

Open sydhds opened 6 months ago

sydhds commented 6 months ago

Here are the main reason for a rewrite of the framework:

bilboquet commented 6 months ago

I'd bet I've already heard this somewhere 🤔 It will probably create many synergies.

sydhds commented 6 months ago

massa-test-framework is used by the following projects:

Note that massa-test-framework has this repo as a dependency:

Note2: Another dependency is Paramiko (in order to launch process remotely).

sydhds commented 6 months ago

TS example code (pseudo code):

import { ServerOpts, Server, Node } from 'XXX';
import { deploySC, WalletClient, ISCData } from '@massalabs/massa-sc-deployer';
import {
  Args,
  fromMAS,
  MAX_GAS_DEPLOYMENT,
  CHAIN_ID,
} from '@massalabs/massa-web3';

//  init a Server (using your computer)
let server_opts = ServerOpts(local=True)
let server = Server(server_opts) 

// create a Node object, use compilation from given path (assuming here it's compiled here in Sandbox mode)
let node1 = Node.from_dev(server, repo=Path("~/dev/massa").expanduser())

// setup config
let cfg = node1.get_config()
cfg["logging"]["level"] = 3
node1.edit_config(cfg)

// Setup initial ledger with existing bytecode and balance
node1.initLedger([{addr: "AU...", bytecode: [1, 0, 3], balance: 2}]);

// start node
let ps = node1.start();

// use massa web3 to do whatever you want with the running node

// get account & client
  const account = await WalletClient.getAccountFromSecretKey(
    account1SecretKey,
  );
  const client = await ClientFactory.createDefaultClient(
    jsonRpcUrlPublic as DefaultProviderUrls,
    chainId,
    false,
    account,
  );

  // deploy smart contract
  const coins = fromMAS(0.5);
  let operationId = await deploySc(
    dataFrom.jsonRpcPublicApi,
    account,
    chainId,
    toDeploy,
    coins,
    new Args()
  );