lbcwallet/votingpool/error_test.go
Guilherme Salgado 2181f4859d votingpool: implement Pool.StartWithdrawal()
<http://opentransactions.org/wiki/index.php/Voting_Pool_Withdrawal_Process>

Also includes some refactorings and other improvements, including better docs
and a new error type (votingpool.Error) used for all votingpool-specific
errors.
2015-04-01 15:55:42 +01:00

82 lines
3.1 KiB
Go

/*
* Copyright (c) 2014 Conformal Systems LLC <info@conformal.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package votingpool_test
import (
"testing"
vp "github.com/btcsuite/btcwallet/votingpool"
)
// TestErrorCodeStringer tests that all error codes has a text
// representation and that text representation is still correct,
// ie. that a refactoring and renaming of the error code has not
// drifted from the textual representation.
func TestErrorCodeStringer(t *testing.T) {
// All the errors in ths
tests := []struct {
in vp.ErrorCode
want string
}{
{vp.ErrInputSelection, "ErrInputSelection"},
{vp.ErrWithdrawalProcessing, "ErrWithdrawalProcessing"},
{vp.ErrUnknownPubKey, "ErrUnknownPubKey"},
{vp.ErrSeriesSerialization, "ErrSeriesSerialization"},
{vp.ErrSeriesVersion, "ErrSeriesVersion"},
{vp.ErrSeriesNotExists, "ErrSeriesNotExists"},
{vp.ErrSeriesAlreadyExists, "ErrSeriesAlreadyExists"},
{vp.ErrSeriesAlreadyEmpowered, "ErrSeriesAlreadyEmpowered"},
{vp.ErrSeriesIDNotSequential, "ErrSeriesIDNotSequential"},
{vp.ErrSeriesIDInvalid, "ErrSeriesIDInvalid"},
{vp.ErrSeriesNotActive, "ErrSeriesNotActive"},
{vp.ErrKeyIsPrivate, "ErrKeyIsPrivate"},
{vp.ErrKeyIsPublic, "ErrKeyIsPublic"},
{vp.ErrKeyNeuter, "ErrKeyNeuter"},
{vp.ErrKeyMismatch, "ErrKeyMismatch"},
{vp.ErrKeysPrivatePublicMismatch, "ErrKeysPrivatePublicMismatch"},
{vp.ErrKeyDuplicate, "ErrKeyDuplicate"},
{vp.ErrTooFewPublicKeys, "ErrTooFewPublicKeys"},
{vp.ErrPoolAlreadyExists, "ErrPoolAlreadyExists"},
{vp.ErrPoolNotExists, "ErrPoolNotExists"},
{vp.ErrScriptCreation, "ErrScriptCreation"},
{vp.ErrTooManyReqSignatures, "ErrTooManyReqSignatures"},
{vp.ErrInvalidBranch, "ErrInvalidBranch"},
{vp.ErrInvalidValue, "ErrInvalidValue"},
{vp.ErrDatabase, "ErrDatabase"},
{vp.ErrKeyChain, "ErrKeyChain"},
{vp.ErrCrypto, "ErrCrypto"},
{vp.ErrRawSigning, "ErrRawSigning"},
{vp.ErrPreconditionNotMet, "ErrPreconditionNotMet"},
{vp.ErrTxSigning, "ErrTxSigning"},
{vp.ErrInvalidScriptHash, "ErrInvalidScriptHash"},
{vp.ErrWithdrawFromUnusedAddr, "ErrWithdrawFromUnusedAddr"},
{0xffff, "Unknown ErrorCode (65535)"},
}
if int(vp.TstLastErr) != len(tests)-1 {
t.Errorf("Wrong number of errorCodeStrings. Got: %d, want: %d",
int(vp.TstLastErr), len(tests))
}
for i, test := range tests {
result := test.in.String()
if result != test.want {
t.Errorf("String #%d\ngot: %s\nwant: %s", i, result,
test.want)
}
}
}