當前位置: 首頁>>代碼示例>>Golang>>正文


Golang votingpool.TstCheckError函數代碼示例

本文整理匯總了Golang中github.com/btcsuite/btcwallet/votingpool.TstCheckError函數的典型用法代碼示例。如果您正苦於以下問題:Golang TstCheckError函數的具體用法?Golang TstCheckError怎麽用?Golang TstCheckError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了TstCheckError函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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:D-bank,項目名稱:btcwallet,代碼行數:8,代碼來源:pool_test.go

示例2: 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:D-bank,項目名稱:btcwallet,代碼行數:8,代碼來源:pool_test.go

示例3: 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:D-bank,項目名稱:btcwallet,代碼行數:8,代碼來源:pool_test.go

示例4: 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:D-bank,項目名稱:btcwallet,代碼行數:8,代碼來源:pool_test.go

示例5: 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:D-bank,項目名稱:btcwallet,代碼行數:10,代碼來源:pool_test.go

示例6: 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:D-bank,項目名稱:btcwallet,代碼行數:12,代碼來源:pool_test.go

示例7: 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:D-bank,項目名稱:btcwallet,代碼行數:13,代碼來源:pool_test.go

示例8: 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:D-bank,項目名稱:btcwallet,代碼行數:13,代碼來源:pool_test.go

示例9: 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:D-bank,項目名稱:btcwallet,代碼行數:14,代碼來源:pool_test.go

示例10: 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:D-bank,項目名稱:btcwallet,代碼行數:14,代碼來源:pool_test.go

示例11: TestPoolChangeAddress

func TestPoolChangeAddress(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.TstNewChangeAddress(t, pool, 1, 0)
	checkPoolAddress(t, addr, 1, 0, 0)

	// When the series is not active, we should get an error.
	pubKeys = vp.TstPubKeys[3:6]
	vp.TstCreateSeries(t, pool,
		[]vp.TstSeriesDef{{ReqSigs: 2, PubKeys: pubKeys, SeriesID: 2, Inactive: true}})
	_, err := pool.ChangeAddress(2, 0)
	vp.TstCheckError(t, "", err, vp.ErrSeriesNotActive)
}
開發者ID:D-bank,項目名稱:btcwallet,代碼行數:17,代碼來源:pool_test.go

示例12: TestEmpowerSeriesErrors

func TestEmpowerSeriesErrors(t *testing.T) {
	tearDown, _, 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)
	}

	tests := []struct {
		seriesID uint32
		key      string
		err      vp.ErrorCode
	}{
		{
			seriesID: 2,
			key:      vp.TstPrivKeys[0],
			// Invalid series.
			err: vp.ErrSeriesNotExists,
		},
		{
			seriesID: seriesID,
			key:      "NONSENSE",
			// Invalid private key.
			err: vp.ErrKeyChain,
		},
		{
			seriesID: seriesID,
			key:      vp.TstPubKeys[5],
			// Wrong type of key.
			err: vp.ErrKeyIsPublic,
		},
		{
			seriesID: seriesID,
			key:      vp.TstPrivKeys[5],
			// Key not corresponding to public key.
			err: vp.ErrKeysPrivatePublicMismatch,
		},
	}

	for i, test := range tests {
		err := pool.EmpowerSeries(test.seriesID, test.key)
		vp.TstCheckError(t, fmt.Sprintf("EmpowerSeries #%d", i), err, test.err)
	}

}
開發者ID:D-bank,項目名稱:btcwallet,代碼行數:46,代碼來源:pool_test.go

示例13: TestEmpowerSeriesNeuterFailed

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

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

	// A private key with bad version (0xffffffff) will trigger an
	// error in (k *ExtendedKey).Neuter and the associated error path
	// in EmpowerSeries.
	badKey := "wM5uZBNTYmaYGiK8VaGi7zPGbZGLuQgDiR2Zk4nGfbRFLXwHGcMUdVdazRpNHFSR7X7WLmzzbAq8dA1ViN6eWKgKqPye1rJTDQTvBiXvZ7E3nmdx"
	err = pool.EmpowerSeries(seriesID, badKey)

	vp.TstCheckError(t, "", err, vp.ErrKeyNeuter)
}
開發者ID:D-bank,項目名稱:btcwallet,代碼行數:18,代碼來源:pool_test.go

示例14: TestPutSeriesErrors

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

	tests := []struct {
		version uint32
		reqSigs uint32
		pubKeys []string
		err     vp.ErrorCode
		msg     string
	}{
		{
			pubKeys: vp.TstPubKeys[0:1],
			err:     vp.ErrTooFewPublicKeys,
			msg:     "Should return error when passed too few pubkeys",
		},
		{
			reqSigs: 5,
			pubKeys: vp.TstPubKeys[0:3],
			err:     vp.ErrTooManyReqSignatures,
			msg:     "Should return error when reqSigs > len(pubKeys)",
		},
		{
			pubKeys: []string{vp.TstPubKeys[0], vp.TstPubKeys[1], vp.TstPubKeys[2], vp.TstPubKeys[0]},
			err:     vp.ErrKeyDuplicate,
			msg:     "Should return error when passed duplicate pubkeys",
		},
		{
			pubKeys: []string{"invalidxpub1", "invalidxpub2", "invalidxpub3"},
			err:     vp.ErrKeyChain,
			msg:     "Should return error when passed invalid pubkey",
		},
		{
			pubKeys: vp.TstPrivKeys[0:3],
			err:     vp.ErrKeyIsPrivate,
			msg:     "Should return error when passed private keys",
		},
	}

	for i, test := range tests {
		err := pool.TstPutSeries(test.version, uint32(i+1), test.reqSigs, test.pubKeys)
		vp.TstCheckError(t, fmt.Sprintf("Create series #%d", i), err, test.err)
	}
}
開發者ID:D-bank,項目名稱:btcwallet,代碼行數:44,代碼來源:pool_test.go

示例15: TestCannotReplaceEmpoweredSeries

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

	seriesID := uint32(1)

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

	vp.TstRunWithManagerUnlocked(t, mgr, func() {
		if err := pool.EmpowerSeries(seriesID, vp.TstPrivKeys[1]); err != nil {
			t.Fatalf("Failed to empower series: %v", err)
		}
	})

	err := pool.ReplaceSeries(1, seriesID, 2, []string{vp.TstPubKeys[0], vp.TstPubKeys[2],
		vp.TstPubKeys[3]})

	vp.TstCheckError(t, "", err, vp.ErrSeriesAlreadyEmpowered)
}
開發者ID:D-bank,項目名稱:btcwallet,代碼行數:21,代碼來源:pool_test.go


注:本文中的github.com/btcsuite/btcwallet/votingpool.TstCheckError函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。