| 128 | } |
| 129 | |
| 130 | func TestSystem_RequestResponse(t *testing.T) { |
| 131 | system := NewSystem("test") |
| 132 | defer system.Shutdown() |
| 133 | |
| 134 | // 创建回声 Actor |
| 135 | pid := system.Spawn(&EchoActor{}, "echo") |
| 136 | |
| 137 | // 发送请求并等待响应 |
| 138 | resp, err := system.Request(pid, &PingMsg{Count: 42}, time.Second) |
| 139 | |
| 140 | require.NoError(t, err) |
| 141 | require.NotNil(t, resp) |
| 142 | |
| 143 | pong, ok := resp.(*PongMsg) |
| 144 | require.True(t, ok) |
| 145 | assert.Equal(t, 42, pong.Count) |
| 146 | } |
| 147 | |
| 148 | func TestSystem_ParentChild(t *testing.T) { |
| 149 | system := NewSystem("test") |