当前位置: 首页>>代码示例>>Golang>>正文


Golang Account.Code方法代码示例

本文整理汇总了Golang中github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account.Account.Code方法的典型用法代码示例。如果您正苦于以下问题:Golang Account.Code方法的具体用法?Golang Account.Code怎么用?Golang Account.Code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account.Account的用法示例。


在下文中一共展示了Account.Code方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: testSNativeCALL

func testSNativeCALL(t *testing.T, expectPass bool, blockCache *BlockCache, doug *acm.Account, snativePerm ptypes.PermFlag, snativeAddress, data []byte, f func([]byte) error) {
	if expectPass {
		doug.Permissions.Base.Set(snativePerm, true)
	}
	var addr []byte
	contractCode := callContractCode(snativeAddress)
	doug.Code = contractCode
	blockCache.UpdateAccount(doug)
	addr = doug.Address
	tx, _ := types.NewCallTx(blockCache, user[0].PubKey, addr, data, 100, 10000, 100)
	tx.Sign(chainID, user[0])
	fmt.Println("subscribing to", types.EventStringAccCall(snativeAddress))
	ev, exception := execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(snativeAddress))
	if exception == ExceptionTimeOut {
		t.Fatal("Timed out waiting for event")
	}
	if expectPass {
		if exception != "" {
			t.Fatal("Unexpected exception", exception)
		}
		evv := ev.(types.EventDataCall)
		ret := evv.Return
		if err := f(ret); err != nil {
			t.Fatal(err)
		}
	} else {
		if exception == "" {
			t.Fatal("Expected exception")
		}
	}
}
开发者ID:ZhuZhengyi,项目名称:eris-db,代码行数:31,代码来源:permissions_test.go

示例2: testSNativeCALLExpectPass

// give a contract perms for an snative, call it, it calls the snative, ensure the check funciton (f) succeeds
func testSNativeCALLExpectPass(t *testing.T, blockCache *BlockCache, doug *account.Account, snativeAddress, data []byte, f func([]byte) error) {
	perm := vm.RegisteredSNativePermissions[LeftPadWord256(snativeAddress)]
	var addr []byte
	if doug != nil {
		contractCode := callContractCode(snativeAddress)
		doug.Code = contractCode
		doug.Permissions.Base.Set(perm, true)
		blockCache.UpdateAccount(doug)
		addr = doug.Address
	} else {
		acc := blockCache.GetAccount(user[0].Address)
		acc.Permissions.Base.Set(perm, true)
		blockCache.UpdateAccount(acc)
		addr = snativeAddress
	}
	tx, _ := types.NewCallTx(blockCache, user[0].PubKey, addr, data, 100, 10000, 100)
	tx.Sign(chainID, user[0])
	ev, exception := execTxWaitEvent(t, blockCache, tx, types.EventStringAccReceive(snativeAddress)) //
	if exception != "" {
		t.Fatal("Unexpected exception", exception)
	}
	evv := ev.(types.EventMsgCall)
	ret := evv.Return
	if err := f(ret); err != nil {
		t.Fatal(err)
	}
}
开发者ID:readevalprint,项目名称:eris-db,代码行数:28,代码来源:permissions_test.go

示例3: testSNativeCALLExpectFail

// assumes the contract has not been given the permission. calls the it, it calls the snative, expects to fail
func testSNativeCALLExpectFail(t *testing.T, blockCache *BlockCache, doug *account.Account, snativeAddress, data []byte) {
	var addr []byte
	if doug != nil {
		contractCode := callContractCode(snativeAddress)
		doug.Code = contractCode
		blockCache.UpdateAccount(doug)
		addr = doug.Address
	} else {
		addr = snativeAddress
	}
	tx, _ := types.NewCallTx(blockCache, user[0].PubKey, addr, data, 100, 10000, 100)
	tx.Sign(chainID, user[0])
	fmt.Println("subscribing to", types.EventStringAccReceive(snativeAddress))
	_, exception := execTxWaitEvent(t, blockCache, tx, types.EventStringAccReceive(snativeAddress))
	if exception == "" {
		t.Fatal("Expected exception")
	}
}
开发者ID:readevalprint,项目名称:eris-db,代码行数:19,代码来源:permissions_test.go


注:本文中的github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account.Account.Code方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。