del test file

parent 97f6c314
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="de83b181-e854-4be8-81f5-73a2fdb02762" name="Default Changelist" comment=""> <list default="true" id="de83b181-e854-4be8-81f5-73a2fdb02762" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gongxianghui/deposit.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/gongxianghui/gongxianghui.go" beforeDir="false" afterPath="$PROJECT_DIR$/gongxianghui/gongxianghui.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gongxianghui/schema.go" beforeDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
...@@ -13,22 +16,19 @@ ...@@ -13,22 +16,19 @@
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/gongxianghui/deposit.go"> <entry file="file://$PROJECT_DIR$/gongxianghui/gongxianghui.go">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="95"> <state relative-caret-position="-3990">
<caret line="5" column="49" selection-start-line="5" selection-start-column="40" selection-end-line="5" selection-end-column="49" /> <caret line="62" column="59" selection-start-line="62" selection-start-column="59" selection-end-line="62" selection-end-column="59" />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/gongxianghui/gongxianghui.go">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/gongxianghui/gongxianghui_test.go"> <entry file="file://$PROJECT_DIR$/gongxianghui/gongxianghui_test.go">
<provider selected="true" editor-type-id="text-editor" /> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-522" />
</provider>
</entry> </entry>
</file> </file>
</leaf> </leaf>
...@@ -37,6 +37,15 @@ ...@@ -37,6 +37,15 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/gongxianghui/schema.go" />
<option value="$PROJECT_DIR$/gongxianghui/gongxianghui.go" />
<option value="$PROJECT_DIR$/gongxianghui/deposit.go" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6"> <component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="1" /> <option name="x" value="1" />
<option name="y" value="25" /> <option name="y" value="25" />
...@@ -49,6 +58,7 @@ ...@@ -49,6 +58,7 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scope" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<expand> <expand>
...@@ -65,7 +75,6 @@ ...@@ -65,7 +75,6 @@
<select /> <select />
</subPane> </subPane>
</pane> </pane>
<pane id="Scope" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
...@@ -90,7 +99,7 @@ ...@@ -90,7 +99,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="RunManager"> <component name="RunManager" selected="Go Test.TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui">
<configuration name="TestGXHCC in github.com/hyperledger/chaincode/gongxianghui" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true"> <configuration name="TestGXHCC in github.com/hyperledger/chaincode/gongxianghui" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<module name="chaincode" /> <module name="chaincode" />
<working_directory value="$PROJECT_DIR$/gongxianghui" /> <working_directory value="$PROJECT_DIR$/gongxianghui" />
...@@ -102,8 +111,20 @@ ...@@ -102,8 +111,20 @@
<pattern value="^TestGXHCC$" /> <pattern value="^TestGXHCC$" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<module name="chaincode" />
<working_directory value="$PROJECT_DIR$/gongxianghui" />
<framework value="gotest" />
<kind value="PACKAGE" />
<package value="github.com/hyperledger/chaincode/gongxianghui" />
<directory value="$PROJECT_DIR$/" />
<filePath value="$PROJECT_DIR$/" />
<pattern value="^TestGXHSchema$" />
<method v="2" />
</configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Go Test.TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui" />
<item itemvalue="Go Test.TestGXHCC in github.com/hyperledger/chaincode/gongxianghui" /> <item itemvalue="Go Test.TestGXHCC in github.com/hyperledger/chaincode/gongxianghui" />
</list> </list>
</recent_temporary> </recent_temporary>
...@@ -112,17 +133,22 @@ ...@@ -112,17 +133,22 @@
<history-entry file="TestGXHCC_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.18 at 18h 01m 03s.xml"> <history-entry file="TestGXHCC_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.18 at 18h 01m 03s.xml">
<configuration name="TestGXHCC in github.com/hyperledger/chaincode/gongxianghui" configurationId="GoTestRunConfiguration" /> <configuration name="TestGXHCC in github.com/hyperledger/chaincode/gongxianghui" configurationId="GoTestRunConfiguration" />
</history-entry> </history-entry>
<history-entry file="TestGXHCC_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 10h 01m 08s.xml">
<configuration name="TestGXHCC in github.com/hyperledger/chaincode/gongxianghui" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestGXHSchema_in_github_com_hyperledger_chaincode_gongxianghui - 2020.02.21 at 10h 03m 03s.xml">
<configuration name="TestGXHSchema in github.com/hyperledger/chaincode/gongxianghui" configurationId="GoTestRunConfiguration" />
</history-entry>
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="67" y="25" width="1853" height="925" extended-state="6" /> <frame x="67" y="25" width="1853" height="925" extended-state="6" />
<editor active="true" />
<layout> <layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.25263157" /> <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.25595567" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" /> <window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" /> <window_info anchor="bottom" id="Find" order="1" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.3308176" /> <window_info anchor="bottom" id="Run" order="2" weight="0.3308176" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" /> <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
...@@ -131,7 +157,7 @@ ...@@ -131,7 +157,7 @@
<window_info anchor="bottom" id="Version Control" order="8" /> <window_info anchor="bottom" id="Version Control" order="8" />
<window_info anchor="bottom" id="Database Changes" order="9" /> <window_info anchor="bottom" id="Database Changes" order="9" />
<window_info anchor="bottom" id="Statistic" order="10" /> <window_info anchor="bottom" id="Statistic" order="10" />
<window_info anchor="bottom" id="Terminal" order="11" /> <window_info active="true" anchor="bottom" id="Terminal" order="11" visible="true" weight="0.32955974" />
<window_info anchor="bottom" id="Event Log" order="12" side_tool="true" /> <window_info anchor="bottom" id="Event Log" order="12" side_tool="true" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
...@@ -144,16 +170,25 @@ ...@@ -144,16 +170,25 @@
<option name="version" value="1" /> <option name="version" value="1" />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/gongxianghui/gongxianghui.go"> <entry file="file://$PROJECT_DIR$/gongxianghui/schema.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="76">
<caret line="8" selection-start-line="8" selection-end-line="8" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/gongxianghui/deposit.go">
<provider selected="true" editor-type-id="text-editor" /> <provider selected="true" editor-type-id="text-editor" />
</entry> </entry>
<entry file="file://$PROJECT_DIR$/gongxianghui/gongxianghui_test.go"> <entry file="file://$PROJECT_DIR$/gongxianghui/gongxianghui_test.go">
<provider selected="true" editor-type-id="text-editor" /> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-522" />
</provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/gongxianghui/deposit.go"> <entry file="file://$PROJECT_DIR$/gongxianghui/gongxianghui.go">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="95"> <state relative-caret-position="-3990">
<caret line="5" column="49" selection-start-line="5" selection-start-column="40" selection-end-line="5" selection-end-column="49" /> <caret line="62" column="59" selection-start-line="62" selection-start-column="59" selection-end-line="62" selection-end-column="59" />
</state> </state>
</provider> </provider>
</entry> </entry>
......
package main
import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
"testing"
)
func TestGXHCC(t *testing.T) {
cc := new(GXHCC)
stub := shim.NewMockStub("GXHCC",cc)
response:= stub.MockInit("init",nil)
fmt.Println(string(response.Payload))
input := `{"aname":"alibusi","aname":"alibus","atype":"type","alinkman":"","aader":"aader","amob":"1234567890","backup":{"id":"1","aname":"alibusi","atype":"type","alinkman":"","aader":"aader","amob":"1234567890"}}`
responseByPut := stub.MockInvoke("invoke1",[][]byte{[]byte("put"), []byte("alibusi"),[]byte(input)})
fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPut.Status,responseByPut.Message,string(responseByPut.Payload))
responseByget := stub.MockInvoke("invoke1",[][]byte{[]byte("get"), []byte("alibusi"),[]byte(input)})
fmt.Printf("Invoke status %d,message %s and payload %s \n",responseByget.Status,responseByget.Message,string(responseByget.Payload))
return
input2 := `{"id":"1","aname":"aaa","atype":"aaa","alinkman":"cc","aader":"aader","amob":"1234567890","backup":{"id":"1","aname":"alibusi","atype":"type","alinkman":"aaa","aader":"aader","amob":"1234567890"}}`
responseByPut2 := stub.MockInvoke("invoke1",[][]byte{[]byte("put"), []byte("alibusi"),[]byte(input2)})
fmt.Printf("Invoke22 status %d,message %s and payload %s\n",responseByPut2.Status,responseByPut2.Message,string(responseByPut2.Payload))
responseByget2 := stub.MockInvoke("invoke1",[][]byte{[]byte("get"), []byte("alibusi"),[]byte(`{"id":"1"}`)})
fmt.Printf("Invoke22 status %d,message %s and payload %s",responseByget2.Status,responseByget2.Message,string(responseByget2.Payload))
}
func TestGXHSchema(t *testing.T){
cc := new(GXHCC)
stub := shim.NewMockStub("GXHCC",cc)
response:= stub.MockInit("init",nil)
fmt.Println("MockInit Payload: ",string(response.Payload))
input := `{"aname":"alibusi","aname":"alibus","atype":"type","alinkman":"","aader":"aader","amob":"1234567890","backup":{"id":"1","aname":"alibusi","atype":"type","alinkman":"","aader":"aader","amob":"1234567890"}}`
responseByPutschema := stub.MockInvoke("invoke1",[][]byte{[]byte("schema"), []byte("put"),[]byte("alibusi"),[]byte(input)})
fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutschema.Status,responseByPutschema.Message,string(responseByPutschema.Payload))
responseByGet := stub.MockInvoke("invoke1",[][]byte{[]byte("schema"), []byte("get"),[]byte("alibusi")})
fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByGet.Status,responseByGet.Message,string(responseByGet.Payload))
fmt.Println()
fmt.Println("========================================right input data============================================")
responseByPut := stub.MockInvoke("invoke1",[][]byte{[]byte("put"), []byte("alibusi"),[]byte(input)})
fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPut.Status,responseByPut.Message,string(responseByPut.Payload))
responseByget := stub.MockInvoke("invoke1",[][]byte{[]byte("get"), []byte("alibusi"),[]byte(`{"id":"1"}`)})
fmt.Printf("Invoke status %d,message %s and payload %s \n",responseByget.Status,responseByget.Message,string(responseByget.Payload))
inputfail := `{"id":"2","atype":"type","alinkman":"","aader":"aader","amob":"1234567890","backup":{"id":"1","aname":"alibusi","atype":"type","alinkman":"","aader":"aader","amob":"1234567890"}}`
fmt.Println()
fmt.Println("========================================fail input data============================================")
responseByPutfail := stub.MockInvoke("invoke1",[][]byte{[]byte("put"), []byte("alibusi"),[]byte(inputfail)})
fmt.Printf("Invoke status %d,message %s and payload %s\n",responseByPutfail.Status,responseByPutfail.Message,string(responseByPutfail.Payload))
responseBygetfail := stub.MockInvoke("invoke1",[][]byte{[]byte("get"), []byte("alibusi"),[]byte(`{"id":"1"}`)})
fmt.Printf("Invoke status %d,message %s and payload %s \n",responseBygetfail.Status,responseBygetfail.Message,string(responseBygetfail.Payload))
}
\ No newline at end of file
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