Commit c4672edf authored by Luke Champine's avatar Luke Champine

use gofmt -s

parent 2e1b3915
......@@ -37,7 +37,7 @@ pkgs = ./api ./build ./compatibility ./crypto ./encoding ./modules ./modules/con
# fmt calls go fmt on all packages.
fmt:
go fmt $(pkgs)
gofmt -s -l -w $(pkgs)
# vet calls go vet on all packages.
# NOTE: go vet requires packages to be built in order to obtain type info.
......
......@@ -42,7 +42,7 @@ func verifyKeysSiag_1_0(uc types.UnlockConditions, folder string, keyname string
}
txn := types.Transaction{
SiafundInputs: []types.SiafundInput{
types.SiafundInput{
{
UnlockConditions: loadedKeys[0].UnlockConditions,
},
},
......
......@@ -154,7 +154,7 @@ func TestUnitCiphertextUnmarshalInvalidJSON(t *testing.T) {
// Test unmarshalling invalid JSON.
invalidJSONBytes := [][]byte{
nil,
[]byte{},
{},
[]byte("\""),
}
for _, jsonBytes := range invalidJSONBytes {
......
......@@ -106,7 +106,7 @@ func TestUnitHashUnmarshalJSON(t *testing.T) {
invalidJSONBytes := [][]byte{
// Invalid JSON.
nil,
[]byte{},
{},
[]byte("\""),
// JSON of wrong length.
[]byte(""),
......
......@@ -222,7 +222,7 @@ func TestUnitValidateHeaderAndBlock(t *testing.T) {
block: mockValidBlock,
// Create a dosBlocks map where mockValidBlock is marked as a bad block.
dosBlocks: map[types.BlockID]struct{}{
mockValidBlock.ID(): struct{}{},
mockValidBlock.ID(): {},
},
earliestValidTimestamp: mockValidBlock.Timestamp,
marshaler: parentBlockUnmarshaler,
......@@ -355,7 +355,7 @@ func TestUnitValidateHeader(t *testing.T) {
header: mockValidBlock.Header(),
// Create a dosBlocks map where mockValidBlock is marked as a bad block.
dosBlocks: map[types.BlockID]struct{}{
mockValidBlock.ID(): struct{}{},
mockValidBlock.ID(): {},
},
blockMapPairs: serializedParentBlockMap,
earliestValidTimestamp: mockValidBlock.Timestamp,
......
......@@ -23,9 +23,9 @@ func TestRPCID(t *testing.T) {
func TestHandlerName(t *testing.T) {
cases := map[string]rpcID{
"": rpcID{},
"foo": rpcID{'f', 'o', 'o'},
"foobarbaz": rpcID{'f', 'o', 'o', 'b', 'a', 'r', 'b', 'a'},
"": {},
"foo": {'f', 'o', 'o'},
"foobarbaz": {'f', 'o', 'o', 'b', 'a', 'r', 'b', 'a'},
}
for s, id := range cases {
if hid := handlerName(s); hid != id {
......@@ -319,7 +319,7 @@ func TestOutboundAndInboundRPCs(t *testing.T) {
// Call the "recv" RPC on g1. We don't know g1's address as g2 sees it, so we
// get it from the first address in g2's peer list.
var addr modules.NetAddress
for p_addr, _ := range g2.peers {
for p_addr := range g2.peers {
addr = p_addr
break
}
......
......@@ -187,7 +187,7 @@ func TestEmptiestStorageFolder(t *testing.T) {
// Single valid storage folder.
{
[]*storageFolder{
&storageFolder{
{
Size: minimumStorageFolderSize,
SizeRemaining: minimumStorageFolderSize,
},
......@@ -197,7 +197,7 @@ func TestEmptiestStorageFolder(t *testing.T) {
// Single full storage folder.
{
[]*storageFolder{
&storageFolder{
{
Size: minimumStorageFolderSize,
SizeRemaining: 0,
},
......@@ -207,7 +207,7 @@ func TestEmptiestStorageFolder(t *testing.T) {
// Single nearly full storage folder.
{
[]*storageFolder{
&storageFolder{
{
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize - 1,
},
......@@ -217,11 +217,11 @@ func TestEmptiestStorageFolder(t *testing.T) {
// Two valid storage folders, first is emptier.
{
[]*storageFolder{
&storageFolder{
{
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize + 1,
},
&storageFolder{
{
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize,
},
......@@ -231,11 +231,11 @@ func TestEmptiestStorageFolder(t *testing.T) {
// Two valid storage folders, second is emptier.
{
[]*storageFolder{
&storageFolder{
{
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize,
},
&storageFolder{
{
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize + 1,
},
......@@ -246,11 +246,11 @@ func TestEmptiestStorageFolder(t *testing.T) {
// hold a new sector.
{
[]*storageFolder{
&storageFolder{
{
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize - 1,
},
&storageFolder{
{
Size: minimumStorageFolderSize * 5,
SizeRemaining: modules.SectorSize,
},
......@@ -261,11 +261,11 @@ func TestEmptiestStorageFolder(t *testing.T) {
// percentage.
{
[]*storageFolder{
&storageFolder{
{
Size: minimumStorageFolderSize * 4,
SizeRemaining: modules.SectorSize * 2,
},
&storageFolder{
{
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize,
},
......@@ -276,11 +276,11 @@ func TestEmptiestStorageFolder(t *testing.T) {
// percentage.
{
[]*storageFolder{
&storageFolder{
{
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize,
},
&storageFolder{
{
Size: minimumStorageFolderSize * 4,
SizeRemaining: modules.SectorSize * 2,
},
......@@ -291,15 +291,15 @@ func TestEmptiestStorageFolder(t *testing.T) {
// volume.
{
[]*storageFolder{
&storageFolder{
{
Size: minimumStorageFolderSize * 4,
SizeRemaining: modules.SectorSize * 2,
},
&storageFolder{
{
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize,
},
&storageFolder{
{
Size: minimumStorageFolderSize * 4,
SizeRemaining: modules.SectorSize * 2,
},
......@@ -309,15 +309,15 @@ func TestEmptiestStorageFolder(t *testing.T) {
// Three storage folders, none have room for a sector.
{
[]*storageFolder{
&storageFolder{
{
Size: minimumStorageFolderSize * 4,
SizeRemaining: modules.SectorSize - 1,
},
&storageFolder{
{
Size: minimumStorageFolderSize,
SizeRemaining: 0,
},
&storageFolder{
{
Size: minimumStorageFolderSize * 4,
SizeRemaining: 1,
},
......
......@@ -94,9 +94,9 @@ func TestNew(t *testing.T) {
func TestContracts(t *testing.T) {
c := &Contractor{
contracts: map[types.FileContractID]Contract{
{1}: Contract{ID: types.FileContractID{1}, IP: "foo"},
{2}: Contract{ID: types.FileContractID{2}, IP: "bar"},
{3}: Contract{ID: types.FileContractID{3}, IP: "baz"},
{1}: {ID: types.FileContractID{1}, IP: "foo"},
{2}: {ID: types.FileContractID{2}, IP: "bar"},
{3}: {ID: types.FileContractID{3}, IP: "baz"},
},
}
for _, contract := range c.Contracts() {
......
......@@ -54,7 +54,7 @@ func TestActiveHosts(t *testing.T) {
h1 := new(hostEntry)
h1.NetAddress = "foo"
hdb.activeHosts = map[modules.NetAddress]*hostNode{
h1.NetAddress: &hostNode{hostEntry: h1},
h1.NetAddress: {hostEntry: h1},
}
if hosts := hdb.ActiveHosts(); len(hosts) != 1 {
t.Errorf("wrong number of hosts: expected %v, got %v", 1, len(hosts))
......@@ -66,8 +66,8 @@ func TestActiveHosts(t *testing.T) {
h2 := new(hostEntry)
h2.NetAddress = "bar"
hdb.activeHosts = map[modules.NetAddress]*hostNode{
h1.NetAddress: &hostNode{hostEntry: h1},
h2.NetAddress: &hostNode{hostEntry: h2},
h1.NetAddress: {hostEntry: h1},
h2.NetAddress: {hostEntry: h2},
}
if hosts := hdb.ActiveHosts(); len(hosts) != 2 {
t.Errorf("wrong number of hosts: expected %v, got %v", 2, len(hosts))
......@@ -116,9 +116,9 @@ func TestAveragePrice(t *testing.T) {
func TestIsOffline(t *testing.T) {
hdb := &HostDB{
allHosts: map[modules.NetAddress]*hostEntry{
"foo.com:1234": &hostEntry{Online: true},
"bar.com:1234": &hostEntry{Online: false},
"baz.com:1234": &hostEntry{Online: true},
"foo.com:1234": {Online: true},
"bar.com:1234": {Online: false},
"baz.com:1234": {Online: true},
},
activeHosts: map[modules.NetAddress]*hostNode{
"foo.com:1234": nil,
......
......@@ -32,9 +32,9 @@ func TestSaveLoad(t *testing.T) {
host3.NetAddress: &host3,
}
hdb.activeHosts = map[modules.NetAddress]*hostNode{
host1.NetAddress: &hostNode{hostEntry: &host1},
host2.NetAddress: &hostNode{hostEntry: &host2},
host3.NetAddress: &hostNode{hostEntry: &host3},
host1.NetAddress: {hostEntry: &host1},
host2.NetAddress: {hostEntry: &host2},
host3.NetAddress: {hostEntry: &host3},
}
hdb.lastChange = modules.ConsensusChangeID{1, 2, 3}
......@@ -121,9 +121,9 @@ func TestRescan(t *testing.T) {
host3.NetAddress: &host3,
}
hdb.activeHosts = map[modules.NetAddress]*hostNode{
host1.NetAddress: &hostNode{hostEntry: &host1},
host2.NetAddress: &hostNode{hostEntry: &host2},
host3.NetAddress: &hostNode{hostEntry: &host3},
host1.NetAddress: {hostEntry: &host1},
host2.NetAddress: {hostEntry: &host2},
host3.NetAddress: {hostEntry: &host3},
}
// use a bogus change ID
......
......@@ -31,7 +31,7 @@ func TestFindHostAnnouncements(t *testing.T) {
}
b := types.Block{
Transactions: []types.Transaction{
types.Transaction{
{
ArbitraryData: [][]byte{annBytes},
},
},
......
......@@ -66,7 +66,7 @@ func relatedObjectIDs(ts []types.Transaction) []ObjectID {
}
var oids []ObjectID
for oid, _ := range oidMap {
for oid := range oidMap {
oids = append(oids, oid)
}
return oids
......
......@@ -37,10 +37,10 @@ func TestAcceptTransactionSetBroadcasts(t *testing.T) {
t.Fatal(err)
}
mockPeers := []modules.Peer{
modules.Peer{Version: "0.0.0"},
modules.Peer{Version: "0.4.6"},
modules.Peer{Version: "0.4.7"},
modules.Peer{Version: "9.9.9"},
{Version: "0.0.0"},
{Version: "0.4.6"},
{Version: "0.4.7"},
{Version: "9.9.9"},
}
mg := &mockGatewayCheckBroadcast{
Gateway: tpt.tpool.gateway,
......
......@@ -76,12 +76,12 @@ func TestUnitProcessConfig(t *testing.T) {
expectedOutputs [][]string
}{
inputs: [][]string{
[]string{"9980", "9981", "9982", "cghmrtwe"},
[]string{":9980", ":9981", ":9982", "CGHMRTWE"},
{"9980", "9981", "9982", "cghmrtwe"},
{":9980", ":9981", ":9982", "CGHMRTWE"},
},
expectedOutputs: [][]string{
[]string{":9980", ":9981", ":9982", "cghmrtwe"},
[]string{":9980", ":9981", ":9982", "cghmrtwe"},
{":9980", ":9981", ":9982", "cghmrtwe"},
{":9980", ":9981", ":9982", "cghmrtwe"},
},
}
var config Config
......
......@@ -64,7 +64,7 @@ func TestBlockHeader(t *testing.T) {
b.Nonce[2] = 2
b.Timestamp = 3
b.MinerPayouts = []SiacoinOutput{{Value: NewCurrency64(4)}}
b.Transactions = []Transaction{{ArbitraryData: [][]byte{[]byte{'5'}}}}
b.Transactions = []Transaction{{ArbitraryData: [][]byte{{'5'}}}}
id1 := b.ID()
id2 := BlockID(crypto.HashBytes(encoding.Marshal(b.Header())))
......@@ -176,7 +176,7 @@ func TestBlockCalculateSubsidy(t *testing.T) {
// Add a single no-fee transaction and check again.
txn = Transaction{
ArbitraryData: [][]byte{[]byte{'6'}},
ArbitraryData: [][]byte{{'6'}},
}
b.Transactions = append(b.Transactions, txn)
if b.CalculateSubsidy(0).Cmp(expected) != 0 {
......@@ -199,7 +199,7 @@ func TestBlockCalculateSubsidy(t *testing.T) {
// Add an empty transaction to the beginning.
txn = Transaction{
ArbitraryData: [][]byte{[]byte{'7'}},
ArbitraryData: [][]byte{{'7'}},
}
b.Transactions = append([]Transaction{txn}, b.Transactions...)
if b.CalculateSubsidy(0).Cmp(expected) != 0 {
......
......@@ -11,7 +11,7 @@ func TestUnlockHash(t *testing.T) {
uc := UnlockConditions{
Timelock: 1,
PublicKeys: []SiaPublicKey{
SiaPublicKey{
{
Algorithm: SignatureEntropy,
Key: []byte{'f', 'a', 'k', 'e'},
},
......@@ -25,22 +25,22 @@ func TestUnlockHash(t *testing.T) {
// TestSigHash runs the SigHash function of the transaction type.
func TestSigHash(t *testing.T) {
txn := Transaction{
SiacoinInputs: []SiacoinInput{SiacoinInput{}},
SiacoinOutputs: []SiacoinOutput{SiacoinOutput{}},
FileContracts: []FileContract{FileContract{}},
FileContractRevisions: []FileContractRevision{FileContractRevision{}},
StorageProofs: []StorageProof{StorageProof{}},
SiafundInputs: []SiafundInput{SiafundInput{}},
SiafundOutputs: []SiafundOutput{SiafundOutput{}},
MinerFees: []Currency{Currency{}},
ArbitraryData: [][]byte{[]byte{'o'}, []byte{'t'}},
SiacoinInputs: []SiacoinInput{{}},
SiacoinOutputs: []SiacoinOutput{{}},
FileContracts: []FileContract{{}},
FileContractRevisions: []FileContractRevision{{}},
StorageProofs: []StorageProof{{}},
SiafundInputs: []SiafundInput{{}},
SiafundOutputs: []SiafundOutput{{}},
MinerFees: []Currency{{}},
ArbitraryData: [][]byte{{'o'}, {'t'}},
TransactionSignatures: []TransactionSignature{
TransactionSignature{
{
CoveredFields: CoveredFields{
WholeTransaction: true,
},
},
TransactionSignature{
{
CoveredFields: CoveredFields{
SiacoinInputs: []uint64{0},
SiacoinOutputs: []uint64{0},
......@@ -101,17 +101,17 @@ func TestTransactionValidCoveredFields(t *testing.T) {
// Create a transaction with all fields filled in minimally. The first
// check has a legal CoveredFields object with 'WholeTransaction' set.
txn := Transaction{
SiacoinInputs: []SiacoinInput{SiacoinInput{}},
SiacoinOutputs: []SiacoinOutput{SiacoinOutput{}},
FileContracts: []FileContract{FileContract{}},
FileContractRevisions: []FileContractRevision{FileContractRevision{}},
StorageProofs: []StorageProof{StorageProof{}},
SiafundInputs: []SiafundInput{SiafundInput{}},
SiafundOutputs: []SiafundOutput{SiafundOutput{}},
MinerFees: []Currency{Currency{}},
ArbitraryData: [][]byte{[]byte{'o'}, []byte{'t'}},
SiacoinInputs: []SiacoinInput{{}},
SiacoinOutputs: []SiacoinOutput{{}},
FileContracts: []FileContract{{}},
FileContractRevisions: []FileContractRevision{{}},
StorageProofs: []StorageProof{{}},
SiafundInputs: []SiafundInput{{}},
SiafundOutputs: []SiafundOutput{{}},
MinerFees: []Currency{{}},
ArbitraryData: [][]byte{{'o'}, {'t'}},
TransactionSignatures: []TransactionSignature{
TransactionSignature{
{
CoveredFields: CoveredFields{
WholeTransaction: true,
},
......
......@@ -445,7 +445,7 @@ func TestTransactionStandaloneValid(t *testing.T) {
txn.FileContractRevisions = nil
// Violate validUnlockConditions
txn.SiacoinInputs = []SiacoinInput{SiacoinInput{}}
txn.SiacoinInputs = []SiacoinInput{{}}
txn.SiacoinInputs[0].UnlockConditions.Timelock = 1
err = txn.StandaloneValid(0)
if err == nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment