Skip to content

Commit

Permalink
Run gofmt against source code (algorand#1797)
Browse files Browse the repository at this point in the history
Run gofmt against source code, and update coding style.
  • Loading branch information
tsachiherman authored Dec 30, 2020
1 parent df98f53 commit 693b673
Show file tree
Hide file tree
Showing 22 changed files with 104 additions and 104 deletions.
2 changes: 1 addition & 1 deletion agreement/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func TestBundleCreationWithEquivocationVotes(t *testing.T) {
require.Error(t, err)

evBadEVBundle := unauthenticatedBundles[4]
evBadEVBundle.EquivocationVotes[0].Sigs = [2]crypto.OneTimeSignature{crypto.OneTimeSignature{}, crypto.OneTimeSignature{}}
evBadEVBundle.EquivocationVotes[0].Sigs = [2]crypto.OneTimeSignature{{}, {}}
_, err = evBadEVBundle.verify(context.Background(), ledger, avv)
require.Error(t, err)

Expand Down
44 changes: 22 additions & 22 deletions agreement/demux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ type demuxTestUsecase struct {
}

var demuxTestUsecases = []demuxTestUsecase{
demuxTestUsecase{
queue: []testChanState{testChanState{eventCount: 1, closed: false}},
{
queue: []testChanState{{eventCount: 1, closed: false}},
rawVotes: testChanState{eventCount: 1, closed: false},
rawProposals: testChanState{eventCount: 0, closed: false},
rawBundles: testChanState{eventCount: 0, closed: false},
Expand All @@ -87,8 +87,8 @@ var demuxTestUsecases = []demuxTestUsecase{
e: messageEvent{Err: makeSerErrStr("QueueEvent-0-0")},
ok: true,
},
demuxTestUsecase{
queue: []testChanState{testChanState{eventCount: 0, closed: true}, testChanState{eventCount: 1, closed: true}},
{
queue: []testChanState{{eventCount: 0, closed: true}, {eventCount: 1, closed: true}},
rawVotes: testChanState{eventCount: 1, closed: false},
rawProposals: testChanState{eventCount: 0, closed: false},
rawBundles: testChanState{eventCount: 0, closed: false},
Expand All @@ -105,8 +105,8 @@ var demuxTestUsecases = []demuxTestUsecase{
e: messageEvent{Err: makeSerErrStr("QueueEvent-1-0")},
ok: true,
},
demuxTestUsecase{
queue: []testChanState{testChanState{eventCount: 0, closed: false}},
{
queue: []testChanState{{eventCount: 0, closed: false}},
rawVotes: testChanState{eventCount: 1, closed: false},
rawProposals: testChanState{eventCount: 0, closed: false},
rawBundles: testChanState{eventCount: 0, closed: false},
Expand All @@ -123,7 +123,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: emptyEvent{},
ok: false,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 0, closed: false},
rawProposals: testChanState{eventCount: 1, closed: false},
Expand All @@ -141,7 +141,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: messageEvent{T: payloadPresent},
ok: true,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 0, closed: false},
rawProposals: testChanState{eventCount: 0, closed: false},
Expand All @@ -159,7 +159,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: messageEvent{T: bundlePresent},
ok: true,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 1, closed: false},
rawProposals: testChanState{eventCount: 1, closed: false},
Expand All @@ -177,7 +177,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: messageEvent{T: bundlePresent},
ok: true,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 1, closed: false},
rawProposals: testChanState{eventCount: 1, closed: false},
Expand All @@ -195,7 +195,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: messageEvent{T: votePresent},
ok: true,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 0, closed: false},
rawProposals: testChanState{eventCount: 1, closed: false},
Expand All @@ -213,7 +213,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: messageEvent{T: bundlePresent},
ok: true,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 0, closed: false},
rawProposals: testChanState{eventCount: 0, closed: false},
Expand All @@ -231,7 +231,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: roundInterruptionEvent{},
ok: true,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 1, closed: false},
rawProposals: testChanState{eventCount: 1, closed: false},
Expand All @@ -249,7 +249,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: emptyEvent{},
ok: false,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 1, closed: false},
rawProposals: testChanState{eventCount: 1, closed: false},
Expand All @@ -267,7 +267,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: roundInterruptionEvent{},
ok: true,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 1, closed: false},
rawProposals: testChanState{eventCount: 1, closed: false},
Expand All @@ -285,7 +285,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: timeoutEvent{T: timeout},
ok: true,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 0, closed: false},
rawProposals: testChanState{eventCount: 0, closed: false},
Expand All @@ -303,7 +303,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: messageEvent{T: voteVerified, Err: makeSerErrStr("Verified-AV-{test_index}-0")},
ok: true,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 0, closed: false},
rawProposals: testChanState{eventCount: 0, closed: false},
Expand All @@ -321,7 +321,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: messageEvent{T: payloadVerified, Err: makeSerErrStr("Verified-PP-{test_index}-0")},
ok: true,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 0, closed: false},
rawProposals: testChanState{eventCount: 0, closed: false},
Expand All @@ -339,7 +339,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: messageEvent{T: bundleVerified, Err: makeSerErrStr("Verified-VB-{test_index}-0")},
ok: true,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 0, closed: true},
rawProposals: testChanState{eventCount: 0, closed: false},
Expand All @@ -357,7 +357,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: emptyEvent{},
ok: false,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 0, closed: false},
rawProposals: testChanState{eventCount: 0, closed: true},
Expand All @@ -375,7 +375,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: emptyEvent{},
ok: false,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 0, closed: false},
rawProposals: testChanState{eventCount: 0, closed: false},
Expand All @@ -393,7 +393,7 @@ var demuxTestUsecases = []demuxTestUsecase{
e: emptyEvent{},
ok: false,
},
demuxTestUsecase{
{
queue: []testChanState{},
rawVotes: testChanState{eventCount: 0, closed: false},
rawProposals: testChanState{eventCount: 1, closed: false},
Expand Down
2 changes: 1 addition & 1 deletion agreement/fuzzer/tests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ func TestRegossipinngElimination(t *testing.T) {
&MessageRegossipFilter{},
},
Schedule: []SchedulerFilterSchedule{
SchedulerFilterSchedule{
{
Operation: 4, // not before
FirstTick: 0, // zero
Nodes: nodesIndices,
Expand Down
2 changes: 1 addition & 1 deletion agreement/vote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func TestEquivocationVoteValidation(t *testing.T) {
_, err = v1.Cred.Verify(config.Consensus[protocol.ConsensusCurrentVersion], m)

noSig := ev
noSig.Sigs = [2]crypto.OneTimeSignature{crypto.OneTimeSignature{}, crypto.OneTimeSignature{}}
noSig.Sigs = [2]crypto.OneTimeSignature{{}, {}}
_, err = noSig.verify(ledger)
require.Error(t, err)

Expand Down
10 changes: 5 additions & 5 deletions crypto/merkletrie/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,22 @@ func (n *node) add(cache *merkleTrieCache, d []byte, path []byte) (nodeID stored

if n.hash[idiff] < d[idiff] {
pnode.children = []childEntry{
childEntry{
{
id: curChildNodeID,
hashIndex: n.hash[idiff],
},
childEntry{
{
id: newChildNodeID,
hashIndex: d[idiff],
},
}
} else {
pnode.children = []childEntry{
childEntry{
{
id: newChildNodeID,
hashIndex: d[idiff],
},
childEntry{
{
id: curChildNodeID,
hashIndex: n.hash[idiff],
},
Expand All @@ -145,7 +145,7 @@ func (n *node) add(cache *merkleTrieCache, d []byte, path []byte) (nodeID stored
pnode2, nodeID2 := cache.allocateNewNode()
pnode2.childrenMask.SetBit(d[i])
pnode2.children = []childEntry{
childEntry{
{
id: nodeID,
hashIndex: d[i],
},
Expand Down
10 changes: 5 additions & 5 deletions daemon/algod/api/server/v1/handlers/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ func TestDecorateUnknownTransactionTypeError(t *testing.T) {
signedKeyregTx := transactions.SignedTxn{Txn: keyregTx}

testCases := []TestCase{
TestCase{
{
err: errors.New(errBlockHashBeenDeletedArchival),
expectedOutcome: errors.New(errBlockHashBeenDeletedArchival),
},
TestCase{
{
err: errors.New(errUnknownTransactionType),
txn: node.TxnWithStatus{Txn: signedPaymentTx, ConfirmedRound: basics.Round(12345)},
expectedOutcome: fmt.Errorf(errInvalidTransactionTypeLedger, paymentTx.Type, paymentTx.ID().String(), basics.Round(12345)),
},
TestCase{
{
err: errors.New(errUnknownTransactionType),
txn: node.TxnWithStatus{Txn: signedKeyregTx, ConfirmedRound: basics.Round(5678)},
expectedOutcome: fmt.Errorf(errInvalidTransactionTypeLedger, keyregTx.Type, keyregTx.ID().String(), basics.Round(5678)),
},
TestCase{
{
err: errors.New(errUnknownTransactionType),
txn: node.TxnWithStatus{Txn: signedPaymentTx},
expectedOutcome: fmt.Errorf(errInvalidTransactionTypePending, paymentTx.Type, paymentTx.ID().String()),
},
TestCase{
{
err: errors.New(errUnknownTransactionType),
txn: node.TxnWithStatus{Txn: signedKeyregTx},
expectedOutcome: fmt.Errorf(errInvalidTransactionTypePending, keyregTx.Type, keyregTx.ID().String()),
Expand Down
2 changes: 1 addition & 1 deletion data/basics/userBalance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestEmptyEncoding(t *testing.T) {

func TestRewards(t *testing.T) {
proto := config.Consensus[protocol.ConsensusCurrentVersion]
accountAlgos := []MicroAlgos{MicroAlgos{Raw: 0}, MicroAlgos{Raw: 8000}, MicroAlgos{Raw: 13000}, MicroAlgos{Raw: 83000}}
accountAlgos := []MicroAlgos{{Raw: 0}, {Raw: 8000}, {Raw: 13000}, {Raw: 83000}}
for _, accountAlgo := range accountAlgos {
ad := AccountData{
Status: Online,
Expand Down
2 changes: 1 addition & 1 deletion data/bookkeeping/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestBlockWithTxnEncoding(t *testing.T) {

var b Block
b.Payset = []transactions.SignedTxnInBlock{
transactions.SignedTxnInBlock{
{
SignedTxnWithAD: transactions.SignedTxnWithAD{
SignedTxn: sigtxn,
},
Expand Down
4 changes: 2 additions & 2 deletions data/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (l *Ledger) Circulation(r basics.Round) (basics.MicroAlgos, error) {
roundCirculation{
elements: [2]roundCirculationPair{
circulation.elements[1],
roundCirculationPair{
{
round: r,
onlineMoney: totals.Online.Money},
},
Expand Down Expand Up @@ -271,7 +271,7 @@ func (l *Ledger) Seed(r basics.Round) (committee.Seed, error) {
roundSeed{
elements: [2]roundSeedPair{
seed.elements[1],
roundSeedPair{
{
round: r,
seed: blockhdr.Seed,
},
Expand Down
2 changes: 1 addition & 1 deletion data/pools/transactionPool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ func TestRemove(t *testing.T) {
}
signedTx := tx.Sign(secrets[0])
require.NoError(t, transactionPool.RememberOne(signedTx))
require.Equal(t, transactionPool.PendingTxGroups(), [][]transactions.SignedTxn{[]transactions.SignedTxn{signedTx}})
require.Equal(t, transactionPool.PendingTxGroups(), [][]transactions.SignedTxn{{signedTx}})
}

func TestLogicSigOK(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions data/transactions/logic/evalStateful_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,8 @@ func TestAssets(t *testing.T) {
}
// check generic errors
sources := []sourceError{
sourceError{"int 5\nint 55\nasset_holding_get AssetBalance", "cannot load account[5]"},
sourceError{"int 5\nasset_params_get AssetTotal", "invalid ForeignAssets index 5"},
{"int 5\nint 55\nasset_holding_get AssetBalance", "cannot load account[5]"},
{"int 5\nasset_params_get AssetTotal", "invalid ForeignAssets index 5"},
}
for _, sourceErr := range sources {
ops, err := AssembleStringWithVersion(sourceErr.src, AssemblerMaxVersion)
Expand Down
2 changes: 1 addition & 1 deletion data/txHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func MakeTxHandler(txPool *pools.TransactionPool, ledger *Ledger, net network.Go
// Start enables the processing of incoming messages at the transaction handler
func (handler *TxHandler) Start() {
handler.net.RegisterHandlers([]network.TaggedMessageHandler{
network.TaggedMessageHandler{Tag: protocol.TxnTag, MessageHandler: network.HandlerFunc(handler.processIncomingTxn)},
{Tag: protocol.TxnTag, MessageHandler: network.HandlerFunc(handler.processIncomingTxn)},
})
handler.backlogWg.Add(1)
go handler.backlogWorker()
Expand Down
2 changes: 1 addition & 1 deletion ledger/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ func (eval *BlockEvaluator) testTransaction(txn transactions.SignedTxn, cow *rou
// an error is returned and the block evaluator state is unchanged.
func (eval *BlockEvaluator) Transaction(txn transactions.SignedTxn, ad transactions.ApplyData) error {
return eval.transactionGroup([]transactions.SignedTxnWithAD{
transactions.SignedTxnWithAD{
{
SignedTxn: txn,
ApplyData: ad,
},
Expand Down
18 changes: 9 additions & 9 deletions ledger/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,15 @@ func TestPrepareAppEvaluators(t *testing.T) {

// Create some groups with these transactions
cases := []evalTestCase{
evalTestCase{[]transactions.SignedTxnWithAD{payment}, []bool{false}},
evalTestCase{[]transactions.SignedTxnWithAD{appcall1}, []bool{true}},
evalTestCase{[]transactions.SignedTxnWithAD{payment, payment}, []bool{false, false}},
evalTestCase{[]transactions.SignedTxnWithAD{appcall1, payment}, []bool{true, false}},
evalTestCase{[]transactions.SignedTxnWithAD{payment, appcall1}, []bool{false, true}},
evalTestCase{[]transactions.SignedTxnWithAD{appcall1, appcall2}, []bool{true, true}},
evalTestCase{[]transactions.SignedTxnWithAD{appcall1, appcall2, appcall1}, []bool{true, true, true}},
evalTestCase{[]transactions.SignedTxnWithAD{payment, appcall1, payment}, []bool{false, true, false}},
evalTestCase{[]transactions.SignedTxnWithAD{appcall1, payment, appcall2}, []bool{true, false, true}},
{[]transactions.SignedTxnWithAD{payment}, []bool{false}},
{[]transactions.SignedTxnWithAD{appcall1}, []bool{true}},
{[]transactions.SignedTxnWithAD{payment, payment}, []bool{false, false}},
{[]transactions.SignedTxnWithAD{appcall1, payment}, []bool{true, false}},
{[]transactions.SignedTxnWithAD{payment, appcall1}, []bool{false, true}},
{[]transactions.SignedTxnWithAD{appcall1, appcall2}, []bool{true, true}},
{[]transactions.SignedTxnWithAD{appcall1, appcall2, appcall1}, []bool{true, true, true}},
{[]transactions.SignedTxnWithAD{payment, appcall1, payment}, []bool{false, true, false}},
{[]transactions.SignedTxnWithAD{appcall1, payment, appcall2}, []bool{true, false, true}},
}

for i, testCase := range cases {
Expand Down
8 changes: 4 additions & 4 deletions ledger/ledger_perf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func makeUnsignedASATx(appIdx uint64, creator basics.Address, round int) transac
creator[:],
creator[:],
creator[:],
[]byte{0, 0, 0, 1, 0, 0, 0, 0},
[]byte{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
}
tx.OnCompletion = transactions.NoOpOC
tx.ApprovalProgram = asaAppovalProgram
Expand Down Expand Up @@ -226,11 +226,11 @@ func benchmarkFullBlocks(params testParams, b *testing.B) {
if createdAppIdx != 0 {
// Creator spends to an opted in acct
tx.ApplicationArgs = [][]byte{
[]byte{0, 0, 0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 1},
}
tx.Accounts = []basics.Address{
accts[j%len(accts)],
basics.Address{},
{},
}
}
default:
Expand Down
Loading

0 comments on commit 693b673

Please sign in to comment.