本文整理汇总了Golang中github.com/stellar/horizon/test.LoadScenario函数的典型用法代码示例。如果您正苦于以下问题:Golang LoadScenario函数的具体用法?Golang LoadScenario怎么用?Golang LoadScenario使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LoadScenario函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestPaymentActions
func TestPaymentActions(t *testing.T) {
test.LoadScenario("base")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("Payment Actions:", t, func() {
Convey("GET /payments", func() {
w := rh.Get("/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 4)
})
Convey("GET /ledgers/:ledger_id/payments", func() {
w := rh.Get("/ledgers/1/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 0)
w = rh.Get("/ledgers/3/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 1)
})
Convey("GET /accounts/:account_id/payments", func() {
w := rh.Get("/accounts/GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 1)
test.LoadScenario("pathed_payment")
w = rh.Get("/accounts/GCQPYGH4K57XBDENKKX55KDTWOTK5WDWRQOH2LHEDX3EKVIQRLMESGBG/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
Convey("GET /transactions/:tx_id/payments", func() {
test.LoadScenario("pathed_payment")
w := rh.Get("/transactions/42450ffe3956b8618cffaae48665c252869440aeb41fd8bf4921929a61982630/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 0)
w = rh.Get("/transactions/95324dec7c94f8cc992522794b2a84a732cddcb5641992589cfe328884a4c132/payments", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 1)
})
})
}
开发者ID:lackac,项目名称:horizon,代码行数:49,代码来源:actions_payment_test.go
示例2: TestHistoryAccountByAddressQuery
func TestHistoryAccountByAddressQuery(t *testing.T) {
test.LoadScenario("base")
Convey("AccountByAddress", t, func() {
var account HistoryAccountRecord
Convey("Existing record behavior", func() {
address := "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"
q := HistoryAccountByAddressQuery{
SqlQuery{history},
address,
}
err := Get(ctx, q, &account)
So(err, ShouldBeNil)
So(account.Id, ShouldEqual, 0)
So(account.Address, ShouldEqual, address)
})
Convey("Missing record behavior", func() {
address := "not real"
q := HistoryAccountByAddressQuery{
SqlQuery{history},
address,
}
err := Get(ctx, q, &account)
So(err, ShouldEqual, ErrNoResults)
})
})
}
开发者ID:lackac,项目名称:horizon,代码行数:30,代码来源:query_history_account_by_address_test.go
示例3: TestOperationByIdQuery
func TestOperationByIdQuery(t *testing.T) {
test.LoadScenario("base")
Convey("OperationByIdQuery", t, func() {
var op OperationRecord
Convey("Existing record behavior", func() {
id := int64(8589938689)
q := OperationByIdQuery{
SqlQuery{history},
id,
}
err := Get(ctx, q, &op)
So(err, ShouldBeNil)
So(op.Id, ShouldEqual, id)
So(op.TransactionId, ShouldEqual, id-1)
})
Convey("Missing record behavior", func() {
id := int64(0)
q := OperationByIdQuery{
SqlQuery{history},
id,
}
err := Get(ctx, q, &op)
So(err, ShouldEqual, ErrNoResults)
})
})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:30,代码来源:query_operation_by_id_test.go
示例4: TestTradeActions
func TestTradeActions(t *testing.T) {
Convey("Trade Actions:", t, func() {
test.LoadScenario("trades")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("GET /accounts/:account_id/trades", func() {
w := rh.Get("/accounts/GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2/trades", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 1)
})
Convey("GET /order_book/trades", func() {
url := "/order_book/trades?" +
"selling_asset_type=credit_alphanum4&" +
"selling_asset_code=EUR&" +
"selling_asset_issuer=GCQPYGH4K57XBDENKKX55KDTWOTK5WDWRQOH2LHEDX3EKVIQRLMESGBG&" +
"buying_asset_type=credit_alphanum4&" +
"buying_asset_code=USD&" +
"buying_asset_issuer=GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4"
w := rh.Get(url, test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 1)
})
})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:29,代码来源:actions_trade_test.go
示例5: TestLedgerActions
func TestLedgerActions(t *testing.T) {
test.LoadScenario("base")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("Ledger Actions:", t, func() {
Convey("GET /ledgers/1", func() {
w := rh.Get("/ledgers/1", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
var result LedgerResource
err := json.Unmarshal(w.Body.Bytes(), &result)
So(err, ShouldBeNil)
So(result.Sequence, ShouldEqual, 1)
})
Convey("GET /ledgers/100", func() {
w := rh.Get("/ledgers/100", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 404)
})
Convey("GET /ledgers", func() {
Convey("With Default Params", func() {
w := rh.Get("/ledgers", test.RequestHelperNoop)
var result map[string]interface{}
err := json.Unmarshal(w.Body.Bytes(), &result)
So(err, ShouldBeNil)
So(w.Code, ShouldEqual, 200)
embedded := result["_embedded"].(map[string]interface{})
records := embedded["records"].([]interface{})
So(len(records), ShouldEqual, 3)
})
Convey("With A Limit", func() {
w := rh.Get("/ledgers?limit=1", test.RequestHelperNoop)
var result map[string]interface{}
err := json.Unmarshal(w.Body.Bytes(), &result)
So(err, ShouldBeNil)
So(w.Code, ShouldEqual, 200)
embedded := result["_embedded"].(map[string]interface{})
records := embedded["records"].([]interface{})
So(len(records), ShouldEqual, 1)
})
})
})
}
开发者ID:raymens,项目名称:horizon,代码行数:60,代码来源:actions_ledger_test.go
示例6: TestPathActions
func TestPathActions(t *testing.T) {
test.LoadScenario("paths")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("Path Actions:", t, func() {
Convey("(no query args): GET /paths", func() {
w := rh.Get("/paths", test.RequestHelperNoop)
t.Log(w.Body.String())
So(w.Code, ShouldEqual, 400)
})
Convey("(happy path): GET /paths?{all args}", func() {
qs := "?destination_account=GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V" +
"&source_account=GARSFJNXJIHO6ULUBK3DBYKVSIZE7SC72S5DYBCHU7DKL22UXKVD7MXP" +
"&destination_asset_type=credit_alphanum4" +
"&destination_asset_code=EUR" +
"&destination_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" +
"&destination_amount=10"
w := rh.Get("/paths"+qs, test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
t.Log(qs)
t.Log(w.Body.String())
So(w.Body, ShouldBePageOf, 4)
})
})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:30,代码来源:actions_path_test.go
示例7: TestAccountActions
func TestAccountActions(t *testing.T) {
Convey("Account Actions:", t, func() {
test.LoadScenario("base")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("GET /accounts/GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", func() {
w := rh.Get("/accounts/GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
var result resource.Account
err := json.Unmarshal(w.Body.Bytes(), &result)
So(err, ShouldBeNil)
So(result.Sequence, ShouldEqual, "3")
})
Convey("GET /accounts/100", func() {
w := rh.Get("/accounts/100", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 404)
})
Convey("GET /accounts", func() {
w := rh.Get("/accounts", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 4)
w = rh.Get("/accounts?limit=1", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 1)
})
})
}
开发者ID:irisli,项目名称:horizon,代码行数:35,代码来源:actions_account_test.go
示例8: TestLedgerPageQuery
func TestLedgerPageQuery(t *testing.T) {
test.LoadScenario("base")
var records []LedgerRecord
Convey("LedgerPageQuery", t, func() {
pq, err := NewPageQuery("", "asc", 2)
So(err, ShouldBeNil)
q := LedgerPageQuery{SqlQuery{history}, pq}
err = Select(ctx, q, &records)
So(err, ShouldBeNil)
So(len(records), ShouldEqual, 2)
So(records, ShouldBeOrderedAscending, func(r interface{}) int64 {
return r.(LedgerRecord).Id
})
lastLedger := records[len(records)-1]
q.Cursor = lastLedger.PagingToken()
err = Select(ctx, q, &records)
So(err, ShouldBeNil)
t.Log(records)
So(len(records), ShouldEqual, 1)
})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:28,代码来源:query_ledger_page_test.go
示例9: TestRootAction
func TestRootAction(t *testing.T) {
Convey("GET /", t, func() {
test.LoadScenario("base")
server := test.NewStaticMockServer(`{
"info": {
"network": "test",
"build": "test-core"
}
}`)
defer server.Close()
app := NewTestApp()
app.horizonVersion = "test-horizon"
app.config.StellarCoreURL = server.URL
defer app.Close()
rh := NewRequestHelper(app)
w := rh.Get("/", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
var result resource.Root
err := json.Unmarshal(w.Body.Bytes(), &result)
So(err, ShouldBeNil)
So(result.HorizonVersion, ShouldEqual, "test-horizon")
So(result.StellarCoreVersion, ShouldEqual, "test-core")
})
}
开发者ID:irisli,项目名称:horizon,代码行数:31,代码来源:actions_root_test.go
示例10: TestAccountByAddressQuery
func TestAccountByAddressQuery(t *testing.T) {
test.LoadScenario("non_native_payment")
Convey("AccountByAddress", t, func() {
var account AccountRecord
notreal := "not_real"
withtl := "GBXGQJWVLWOYHFLVTKWV5FGHA3LNYY2JQKM7OAJAUEQFU6LPCSEFVXON"
notl := "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"
q := AccountByAddressQuery{
Core: SqlQuery{core},
History: SqlQuery{history},
Address: withtl,
}
err := Get(ctx, q, &account)
So(err, ShouldBeNil)
So(account.Address, ShouldEqual, withtl)
So(account.Seqnum, ShouldEqual, 8589934593)
So(len(account.Trustlines), ShouldEqual, 1)
q.Address = notl
err = Get(ctx, q, &account)
So(err, ShouldBeNil)
So(len(account.Trustlines), ShouldEqual, 0)
q.Address = notreal
err = Get(ctx, q, &account)
So(err, ShouldEqual, ErrNoResults)
})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:33,代码来源:query_account_by_address_test.go
示例11: TestLedgerBySequenceQuery
func TestLedgerBySequenceQuery(t *testing.T) {
Convey("LedgerBySequenceQuery", t, func() {
test.LoadScenario("base")
var record LedgerRecord
Convey("Existing record behavior", func() {
sequence := int32(2)
q := LedgerBySequenceQuery{
SqlQuery{history},
sequence,
}
err := Get(ctx, q, &record)
So(err, ShouldBeNil)
So(record.Sequence, ShouldEqual, sequence)
})
Convey("Missing record behavior", func() {
sequence := int32(-1)
query := LedgerBySequenceQuery{
SqlQuery{history},
sequence,
}
err := Get(ctx, query, &record)
So(err, ShouldEqual, ErrNoResults)
})
})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:28,代码来源:query_ledger_by_sequence_test.go
示例12: TestFinder
func TestFinder(t *testing.T) {
Convey("Finder", t, func() {
test.LoadScenario("paths")
conn := test.OpenDatabase(test.StellarCoreDatabaseUrl())
defer conn.Close()
finder := &Finder{
Ctx: test.Context(),
SqlQuery: db.SqlQuery{conn},
}
native := makeAsset(xdr.AssetTypeAssetTypeNative, "", "")
usd := makeAsset(
xdr.AssetTypeAssetTypeCreditAlphanum4,
"USD",
"GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")
eur := makeAsset(
xdr.AssetTypeAssetTypeCreditAlphanum4,
"EUR",
"GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")
Convey("Find", func() {
query := paths.Query{
DestinationAddress: "GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V",
DestinationAsset: eur,
DestinationAmount: xdr.Int64(200000000),
SourceAssets: []xdr.Asset{usd},
}
paths, err := finder.Find(query)
So(err, ShouldBeNil)
So(len(paths), ShouldEqual, 4)
query.DestinationAmount = xdr.Int64(200000001)
paths, err = finder.Find(query)
So(err, ShouldBeNil)
So(len(paths), ShouldEqual, 2)
query.DestinationAmount = xdr.Int64(500000001)
paths, err = finder.Find(query)
So(err, ShouldBeNil)
So(len(paths), ShouldEqual, 0)
})
Convey("regression: paths that involve native currencies can be found", func() {
query := paths.Query{
DestinationAddress: "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN",
DestinationAsset: native,
DestinationAmount: xdr.Int64(1),
SourceAssets: []xdr.Asset{usd, native},
}
paths, err := finder.Find(query)
So(err, ShouldBeNil)
So(len(paths), ShouldEqual, 2)
})
})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:60,代码来源:finder_test.go
示例13: TestEffectActions
func TestEffectActions(t *testing.T) {
test.LoadScenario("base")
Convey("Effect Actions:", t, func() {
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("GET /effects", func() {
w := rh.Get("/effects?limit=20", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 11)
// test streaming, regression for https://github.com/stellar/horizon/issues/147
w = rh.Get("/effects?limit=2", test.RequestHelperStreaming)
So(w.Code, ShouldEqual, 200)
})
Convey("GET /ledgers/:ledger_id/effects", func() {
w := rh.Get("/ledgers/1/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 0)
w = rh.Get("/ledgers/2/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 9)
w = rh.Get("/ledgers/3/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 2)
})
Convey("GET /accounts/:account_id/effects", func() {
w := rh.Get("/accounts/GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
w = rh.Get("/accounts/GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 2)
w = rh.Get("/accounts/GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
Convey("GET /transactions/:tx_id/effects", func() {
w := rh.Get("/transactions/2374e99349b9ef7dba9a5db3339b78fda8f34777b1af33ba468ad5c0df946d4d/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
Convey("GET /operations/:op_id/effects", func() {
w := rh.Get("/operations/8589938689/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
})
}
开发者ID:FihlaTV,项目名称:horizon,代码行数:59,代码来源:actions_effects_test.go
示例14: TestEffectActions
func TestEffectActions(t *testing.T) {
test.LoadScenario("base")
Convey("Effect Actions:", t, func() {
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("GET /effects", func() {
w := rh.Get("/effects?limit=20", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 11)
})
Convey("GET /ledgers/:ledger_id/effects", func() {
w := rh.Get("/ledgers/1/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 0)
w = rh.Get("/ledgers/2/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 9)
w = rh.Get("/ledgers/3/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 2)
})
Convey("GET /accounts/:account_id/effects", func() {
w := rh.Get("/accounts/GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
w = rh.Get("/accounts/GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 2)
w = rh.Get("/accounts/GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
Convey("GET /transactions/:tx_id/effects", func() {
w := rh.Get("/transactions/c492d87c4642815dfb3c7dcce01af4effd162b031064098a0d786b6e0a00fd74/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
Convey("GET /operations/:op_id/effects", func() {
w := rh.Get("/operations/8589938689/effects", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
})
}
开发者ID:lackac,项目名称:horizon,代码行数:55,代码来源:actions_effects_test.go
示例15: TestEffectPageQueryByOrderBook
func TestEffectPageQueryByOrderBook(t *testing.T) {
test.LoadScenario("trades")
Convey("EffectOrderBookFilter", t, func() {
var records []EffectRecord
Convey("restricts to order book properly", func() {
q := EffectPageQuery{
SqlQuery: SqlQuery{history},
PageQuery: MustPageQuery("", "asc", 0),
Filter: &EffectOrderBookFilter{
SellingType: xdr.AssetTypeAssetTypeCreditAlphanum4,
SellingCode: "EUR",
SellingIssuer: "GCQPYGH4K57XBDENKKX55KDTWOTK5WDWRQOH2LHEDX3EKVIQRLMESGBG",
BuyingType: xdr.AssetTypeAssetTypeCreditAlphanum4,
BuyingCode: "USD",
BuyingIssuer: "GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4",
},
}
MustSelect(ctx, q, &records)
So(len(records), ShouldEqual, 1)
r := records[0]
var dets map[string]interface{}
_ = r.UnmarshalDetails(&dets)
So(dets["sold_asset_type"].(string), ShouldEqual, "credit_alphanum4")
So(dets["sold_asset_code"], ShouldEqual, "EUR")
So(dets["sold_asset_issuer"], ShouldEqual, "GCQPYGH4K57XBDENKKX55KDTWOTK5WDWRQOH2LHEDX3EKVIQRLMESGBG")
So(dets["bought_asset_type"].(string), ShouldEqual, "credit_alphanum4")
So(dets["bought_asset_code"], ShouldEqual, "USD")
So(dets["bought_asset_issuer"], ShouldEqual, "GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4")
})
Convey("regression: does not crash when using a native asset", func() {
q := EffectPageQuery{
SqlQuery: SqlQuery{history},
PageQuery: MustPageQuery("", "asc", 0),
Filter: &EffectOrderBookFilter{
SellingType: xdr.AssetTypeAssetTypeNative,
BuyingType: xdr.AssetTypeAssetTypeCreditAlphanum4,
BuyingCode: "USD",
BuyingIssuer: "GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4",
},
}
MustSelect(ctx, q, &records)
})
})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:53,代码来源:query_effect_page_test.go
示例16: TestRootAction
func TestRootAction(t *testing.T) {
Convey("GET /", t, func() {
test.LoadScenario("base")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
w := rh.Get("/", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
})
}
开发者ID:lackac,项目名称:horizon,代码行数:13,代码来源:actions_root_test.go
示例17: TestLedgerState
func TestLedgerState(t *testing.T) {
test.LoadScenario("base")
horizon := OpenTestDatabase()
defer horizon.Close()
core := OpenStellarCoreTestDatabase()
defer core.Close()
Convey("db.UpdateLedgerState", t, func() {
So(horizonLedgerGauge.Value(), ShouldEqual, 0)
So(stellarCoreLedgerGauge.Value(), ShouldEqual, 0)
UpdateLedgerState(test.Context(), SqlQuery{horizon}, SqlQuery{core})
So(horizonLedgerGauge.Value(), ShouldEqual, 3)
So(stellarCoreLedgerGauge.Value(), ShouldEqual, 3)
})
}
开发者ID:lackac,项目名称:horizon,代码行数:17,代码来源:ledger_state_test.go
示例18: TestLedgerStateQuery
func TestLedgerStateQuery(t *testing.T) {
test.LoadScenario("base")
Convey("LedgerStateQuery", t, func() {
var ls LedgerState
q := LedgerStateQuery{
SqlQuery{history},
SqlQuery{core},
}
err := Get(ctx, q, &ls)
So(err, ShouldBeNil)
So(ls.HorizonSequence, ShouldEqual, 3)
So(ls.StellarCoreSequence, ShouldEqual, 3)
})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:17,代码来源:query_ledger_state_test.go
示例19: TestOfferActions
func TestOfferActions(t *testing.T) {
test.LoadScenario("trades")
app := NewTestApp()
defer app.Close()
rh := NewRequestHelper(app)
Convey("Offer Actions:", t, func() {
Convey("GET /accounts/GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2/offers", func() {
w := rh.Get("/accounts/GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2/offers", test.RequestHelperNoop)
So(w.Code, ShouldEqual, 200)
So(w.Body, ShouldBePageOf, 3)
})
})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:17,代码来源:actions_offer_test.go
示例20: TestOrderBook
func TestOrderBook(t *testing.T) {
Convey("orderBook", t, func() {
test.LoadScenario("paths")
conn := test.OpenDatabase(test.StellarCoreDatabaseUrl())
defer conn.Close()
ob := orderBook{
Selling: makeAsset(
xdr.AssetTypeAssetTypeCreditAlphanum4,
"EUR",
"GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN"),
Buying: makeAsset(
xdr.AssetTypeAssetTypeCreditAlphanum4,
"USD",
"GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN"),
DB: db.SqlQuery{conn},
}
Convey("Cost", func() {
r, err := ob.Cost(ob.Buying, 10)
So(err, ShouldBeNil)
So(r, ShouldEqual, xdr.Int64(10))
// this cost should consume the entire lowest priced order, whose price
// is 1.0, thus the output should be the same
r, err = ob.Cost(ob.Buying, 100000000)
So(err, ShouldBeNil)
So(r, ShouldEqual, xdr.Int64(100000000))
// now we are taking from the next offer, where the price is 2.0
r, err = ob.Cost(ob.Buying, 100000001)
So(err, ShouldBeNil)
So(r, ShouldEqual, xdr.Int64(100000002))
r, err = ob.Cost(ob.Buying, 500000000)
So(err, ShouldBeNil)
So(r, ShouldEqual, xdr.Int64(900000000))
r, err = ob.Cost(ob.Buying, 500000001)
So(err, ShouldNotBeNil)
})
})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:44,代码来源:order_book_test.go
注:本文中的github.com/stellar/horizon/test.LoadScenario函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论