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


Golang votingpool.TstCreatePool函数代码示例

本文整理汇总了Golang中github.com/conseweb/stcwallet/votingpool.TstCreatePool函数的典型用法代码示例。如果您正苦于以下问题:Golang TstCreatePool函数的具体用法?Golang TstCreatePool怎么用?Golang TstCreatePool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: TestLoadPoolAndDepositScript

func TestLoadPoolAndDepositScript(t *testing.T) {
	tearDown, manager, pool := vp.TstCreatePool(t)
	defer tearDown()
	// setup
	poolID := "test"
	pubKeys := vp.TstPubKeys[0:3]
	err := vp.LoadAndCreateSeries(pool.TstNamespace(), manager, 1, poolID, 1, 2, pubKeys)
	if err != nil {
		t.Fatalf("Failed to create voting pool and series: %v", err)
	}

	// execute
	script, err := vp.LoadAndGetDepositScript(pool.TstNamespace(), manager, poolID, 1, 0, 0)
	if err != nil {
		t.Fatalf("Failed to get deposit script: %v", err)
	}

	// validate
	strScript := hex.EncodeToString(script)
	want := "5221035e94da75731a2153b20909017f62fcd49474c45f3b46282c0dafa8b40a3a312b2102e983a53dd20b7746dd100dfd2925b777436fc1ab1dd319433798924a5ce143e32102908d52a548ee9ef6b2d0ea67a3781a0381bc3570ad623564451e63757ff9393253ae"
	if want != strScript {
		t.Fatalf("Failed to get the right deposit script. Got %v, want %v",
			strScript, want)
	}
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:25,代码来源:pool_test.go

示例2: TestPoolCreateSeriesInvalidID

func TestPoolCreateSeriesInvalidID(t *testing.T) {
	tearDown, _, pool := vp.TstCreatePool(t)
	defer tearDown()

	err := pool.CreateSeries(vp.CurrentVersion, 0, 1, vp.TstPubKeys[0:3])

	vp.TstCheckError(t, "", err, vp.ErrSeriesIDInvalid)
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:8,代码来源:pool_test.go

示例3: TestDepositScriptAddressForNonExistentSeries

func TestDepositScriptAddressForNonExistentSeries(t *testing.T) {
	tearDown, _, pool := vp.TstCreatePool(t)
	defer tearDown()

	_, err := pool.DepositScriptAddress(1, 0, 0)

	vp.TstCheckError(t, "", err, vp.ErrSeriesNotExists)
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:8,代码来源:pool_test.go

示例4: TestDecryptExtendedKeyCannotDecrypt

func TestDecryptExtendedKeyCannotDecrypt(t *testing.T) {
	tearDown, _, pool := vp.TstCreatePool(t)
	defer tearDown()

	_, err := pool.TstDecryptExtendedKey(waddrmgr.CKTPublic, []byte{})

	vp.TstCheckError(t, "", err, vp.ErrCrypto)
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:8,代码来源:pool_test.go

示例5: TestCreatePoolWhenAlreadyExists

func TestCreatePoolWhenAlreadyExists(t *testing.T) {
	tearDown, mgr, pool := vp.TstCreatePool(t)
	defer tearDown()

	_, err := vp.Create(pool.TstNamespace(), mgr, pool.ID)

	vp.TstCheckError(t, "", err, vp.ErrPoolAlreadyExists)
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:8,代码来源:pool_test.go

示例6: TestReplaceNonExistingSeries

func TestReplaceNonExistingSeries(t *testing.T) {
	tearDown, _, pool := vp.TstCreatePool(t)
	defer tearDown()

	pubKeys := vp.TstPubKeys[0:3]

	err := pool.ReplaceSeries(1, 1, 3, pubKeys)

	vp.TstCheckError(t, "", err, vp.ErrSeriesNotExists)
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:10,代码来源:pool_test.go

示例7: TestLoadPool

func TestLoadPool(t *testing.T) {
	tearDown, mgr, pool := vp.TstCreatePool(t)
	defer tearDown()

	pool2, err := vp.Load(pool.TstNamespace(), mgr, pool.ID)
	if err != nil {
		t.Errorf("Error loading Pool: %v", err)
	}
	if !bytes.Equal(pool2.ID, pool.ID) {
		t.Errorf("Voting pool obtained from DB does not match the created one")
	}
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:12,代码来源:pool_test.go

示例8: TestPoolCreateSeriesWhenAlreadyExists

func TestPoolCreateSeriesWhenAlreadyExists(t *testing.T) {
	tearDown, _, pool := vp.TstCreatePool(t)
	defer tearDown()
	pubKeys := vp.TstPubKeys[0:3]
	if err := pool.CreateSeries(1, 1, 1, pubKeys); err != nil {
		t.Fatalf("Cannot create series: %v", err)
	}

	err := pool.CreateSeries(1, 1, 1, pubKeys)

	vp.TstCheckError(t, "", err, vp.ErrSeriesAlreadyExists)
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:12,代码来源:pool_test.go

示例9: TestCreatePool

func TestCreatePool(t *testing.T) {
	tearDown, mgr, pool := vp.TstCreatePool(t)
	defer tearDown()

	pool2, err := vp.Create(pool.TstNamespace(), mgr, []byte{0x02})
	if err != nil {
		t.Errorf("Error creating Pool: %v", err)
	}
	if !bytes.Equal(pool2.ID, []byte{0x02}) {
		t.Errorf("Pool ID mismatch: got %v, want %v", pool2.ID, []byte{0x02})
	}
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:12,代码来源:pool_test.go

示例10: TestDepositScriptAddressForHardenedPubKey

func TestDepositScriptAddressForHardenedPubKey(t *testing.T) {
	tearDown, _, pool := vp.TstCreatePool(t)
	defer tearDown()
	if err := pool.CreateSeries(1, 1, 2, vp.TstPubKeys[0:3]); err != nil {
		t.Fatalf("Cannot creates series")
	}

	// Ask for a DepositScriptAddress using an index for a hardened child, which should
	// fail as we use the extended public keys to derive childs.
	_, err := pool.DepositScriptAddress(1, 0, vp.Index(hdkeychain.HardenedKeyStart+1))

	vp.TstCheckError(t, "", err, vp.ErrKeyChain)
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:13,代码来源:pool_test.go

示例11: TestPoolCreateSeriesIDNotSequential

func TestPoolCreateSeriesIDNotSequential(t *testing.T) {
	tearDown, _, pool := vp.TstCreatePool(t)
	defer tearDown()

	pubKeys := vp.TstPubKeys[0:4]
	if err := pool.CreateSeries(1, 1, 2, pubKeys); err != nil {
		t.Fatalf("Cannot create series: %v", err)
	}

	err := pool.CreateSeries(1, 3, 2, pubKeys)

	vp.TstCheckError(t, "", err, vp.ErrSeriesIDNotSequential)
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:13,代码来源:pool_test.go

示例12: TestPoolWithdrawalAddress

func TestPoolWithdrawalAddress(t *testing.T) {
	tearDown, _, pool := vp.TstCreatePool(t)
	defer tearDown()

	pubKeys := vp.TstPubKeys[1:4]
	vp.TstCreateSeries(t, pool, []vp.TstSeriesDef{{ReqSigs: 2, PubKeys: pubKeys, SeriesID: 1}})
	addr := vp.TstNewWithdrawalAddress(t, pool, 1, 0, 0)
	checkPoolAddress(t, addr, 1, 0, 0)

	// When the requested address is not present in the set of used addresses
	// for that Pool, we should get an error.
	_, err := pool.WithdrawalAddress(1, 2, 3)
	vp.TstCheckError(t, "", err, vp.ErrWithdrawFromUnusedAddr)
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:14,代码来源:pool_test.go

示例13: TestDecryptExtendedKeyCannotCreateResultKey

func TestDecryptExtendedKeyCannotCreateResultKey(t *testing.T) {
	tearDown, mgr, pool := vp.TstCreatePool(t)
	defer tearDown()

	// the plaintext not being base58 encoded triggers the error
	cipherText, err := mgr.Encrypt(waddrmgr.CKTPublic, []byte("not-base58-encoded"))
	if err != nil {
		t.Fatalf("Failed to encrypt plaintext: %v", err)
	}

	_, err = pool.TstDecryptExtendedKey(waddrmgr.CKTPublic, cipherText)

	vp.TstCheckError(t, "", err, vp.ErrKeyChain)
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:14,代码来源:pool_test.go

示例14: TestCreateSeries

func TestCreateSeries(t *testing.T) {
	tearDown, _, pool := vp.TstCreatePool(t)
	defer tearDown()

	tests := []struct {
		version uint32
		series  uint32
		reqSigs uint32
		pubKeys []string
	}{
		{
			version: 1,
			series:  1,
			reqSigs: 2,
			pubKeys: vp.TstPubKeys[0:3],
		},
		{
			version: 1,
			series:  2,
			reqSigs: 3,
			pubKeys: vp.TstPubKeys[0:5],
		},
		{
			version: 1,
			series:  3,
			reqSigs: 4,
			pubKeys: vp.TstPubKeys[0:7],
		},
		{
			version: 1,
			series:  4,
			reqSigs: 5,
			pubKeys: vp.TstPubKeys[0:9],
		},
	}

	for testNum, test := range tests {
		err := pool.CreateSeries(test.version, test.series, test.reqSigs, test.pubKeys[:])
		if err != nil {
			t.Fatalf("%d: Cannot create series %d", testNum, test.series)
		}
		exists, err := pool.TstExistsSeries(test.series)
		if err != nil {
			t.Fatal(err)
		}
		if !exists {
			t.Errorf("%d: Series %d not in database", testNum, test.series)
		}
	}
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:50,代码来源:pool_test.go

示例15: TestEmpowerSeries

func TestEmpowerSeries(t *testing.T) {
	tearDown, mgr, pool := vp.TstCreatePool(t)
	defer tearDown()

	seriesID := uint32(1)
	if err := pool.CreateSeries(1, seriesID, 2, vp.TstPubKeys[0:3]); err != nil {
		t.Fatalf("Failed to create series: %v", err)
	}

	vp.TstRunWithManagerUnlocked(t, mgr, func() {
		if err := pool.EmpowerSeries(seriesID, vp.TstPrivKeys[0]); err != nil {
			t.Errorf("Failed to empower series: %v", err)
		}
	})
}
开发者ID:conseweb,项目名称:stcwallet,代码行数:15,代码来源:pool_test.go


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